Using the below code, i could pre-fill input elements of a form,
<?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 for the above is,
title: temp_12
but how to achieve that, for this kind of dynamic table,
<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>
and txt.txt file is
Vector: 23 34 43 54
i tried to include php inside JavaScript input elements like value=, but this does not generate the table, is there any way to achieve this ?