嗨,我正在尝试在按钮单击上生成表格行,但我的问题是组合框,它从 mysql 数据库加载数据,任何人都可以帮助我如何在 mysql 中使用 javascript 这是我的 javascript 代码
<script language="javascript" type="text/javascript">
var i=1;
function addalRow()
{
var tbl = document.getElementById('alimtable');
var lastRow = tbl.rows.length;
var iteration = lastRow - 1;
var row = tbl.insertRow(lastRow);
var firstCell = row.insertCell(0);
var el = document.createElement('input');
el.type = 'text';
el.name = 'alimname_' + i;
el.id = 'alimname_' + i;
el.size = 40;
el.maxlength = 40;
firstCell.appendChild(el);
var secondCell = row.insertCell(1);
var el2 = document.createElement('input');
el2.type = 'text';
el2.name = 'alimmob_' + i;
el2.id = 'alimmob_' + i;
el2.size = 13;
el2.maxlength = 13;
secondCell.appendChild(el2);
var thirdCell = row.insertCell(2);
var e13 = document.getElementsByName('qabil')[0];
e13.setAttribute('name',e13.getAttribute('name')+'_'+
i);//change the select's name
thirdCell.appendChild(e13);
// alert(i);
i++;
makhtab.r.value=i;
// alert(i);
}
</script>
这是我的表格代码
<table border="1px" id="alimtable" size="100px" cellspacing="0" cellpadding="2">
<tr>
<td><strong>Muallim Name</strong></td>
<td><strong>Mobile</strong> </td>
<td><strong>Qabiliyat</strong> </td>
</tr>
<tr>
<td><input name="alimame_0" type="text" id="zimname_0" size="40" maxlength="20" /></td>
<td><input name="alimmob_0" type="text" id="zimmob_0" size="13" maxlength="20" /></td>
<td><select id="qabil" name="qabil" class="element text large" style="font-size:14px;"/>
<option value=""></option>
<?php
$result = mysql_query("SELECT code, `name` from qabiliyat ") or die(mysql_error());
while ($qab = mysql_fetch_array($result)) {
echo "<option value='$qab[code]'>$qab[name]</option>";
}
?>
</select></td>
</tr>
</table>
<input type="button" value="Add" onclick="addalRow();" /><input name="h" type="hidden" id="r" value="1" />