簡體   English   中英

是否可以使用php預填充動態html表的值?

[英]is it possible to pre-fill the values of a dynamic html table using php?

使用以下代碼,我可以預先填寫表單的輸入元素,

      <?PHP

       $filename = 'txt.txt';
     $str = file_get_contents($filename);
     for ($y=5; $y<=10;$y++){
     if($data[$y][0]=="PROJECT TITLE"){
    $projecttitle= $data[$y][1];}
      } ?>

          <tr>
  <th>Project Title: </th>
  <td><span class="dropt">
  <input id="projecttitle" onkeyup="ProjectTitleValidate()" value="<?php echo $projecttitle ?>" autocomplete="off" type="text" maxlength="50" name="projecttitle" title="Project Title for reference!">
  </td>
  </tr>

上面的txt.txt是,

 title: temp_12

但是對於這種動態表,如何實現

    <script>
      function buildTable(val)
 {
 var myTable =document.getElementById("contentTable");
 var j=val;
 var r1=val;
var rows = [];
 var cells = [];

 while (myTable.hasChildNodes()) {
    myTable.removeChild(myTable.lastChild);
}


for( var i = 0; i < 1; i++ )
{
    rows[i] = myTable.insertRow(i);
    if(i%3==2)rows[i].addClass("every3rdrow");
    cells[i] = [];

    for( var x = 0; x < j ; x++ )
    {
        cells[i][x] =document.createElement((x==0)?"th":"td");
        cells[i][x].innerHTML = (x==0)?"<input id=t onchange=ty() name=t[] size=3>":"<input id=t1 onchange=ty1() name=t1[] size=3>";
        rows[rows.length - 1].appendChild(cells[i][x]);
    }
     }

      }
  buildTable(); 
 </script>

          <tr>
  <th>Number of Models:<title="Number of Models"></th>

  <td><select id="numbermodels" name="numbermodels" onmouseover="buildTable(this.value)" onchange="buildTable(this.value);buildTable4(this.value);">

  <option value="1">1</option >
  <option selected="selected" value="2">2</option >
  <option value="3">3</option >
  <option value="4">4</option >
  <option value="5">5</option >
  <option value="6">6</option >
  </select></td>
  </tr>

  <tr>
  <th>Number of heads per model:</th>
  <td>
  <table id="contentTable" border="1" name="contentTable">
    <!-- Fill table programmatically -->
</table></td>
  </tr>

和txt.txt文件是

      Vector: 23 34 43 54

我試圖在PHP輸入元素(例如value =)中包含php,但這不會生成表,有沒有辦法實現這一點?

我比程序員更像是設計師-因此,我將提供答復,這可能會激起某些REAL程序員的響應。

在搜索網站上的事件日歷和圖庫頁面的類似功能的自動化程序時,發現了以下代碼。 我的網站需要將各種文本詳細信息插入到日期協調的信息字段中-結合日歷和事件信息,進行交叉鏈接。

帶有RSPA程序的SourceCode頁面的URL: http : //sourceforge.net/projects/rspa/files/

RSPA是用於PHP4和PHP 5的基於組件的事件驅動ajax啟用框架。它是平面PHP類和HTML的組合。

使用此框架,您可以從客戶端控件事件中調用服務器端PHP類函數。 在服務器端功能中,您可以直接操作客戶端對象。

我使用Prototype和script.aculo.us!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM