如何使用javascript在动态表中添加动态下拉选择,但我想在cell6.innerHTML=
而不是使用这个选择input type="text"
?
<script type="text/javascript">
var i = 0;
function changeIt(){
i++;
var table=document.getElementById("itemdetail");
var row=table.insertRow();
var cell4=row.insertCell();
var cell3=row.insertCell();
var cell1=row.insertCell();
var cell7=row.insertCell();
var cell5=row.insertCell();
var cell6=row.insertCell();
cell6.innerHTML="<input style='width:104px'
type='text' readonly='readonly' name='itemcode[]' id='itemcode"+i+"' />";
cell5.innerHTML="<input type='text'
name='particulars[]' id='particulars"+i+"'/>";
cell7.innerHTML="<textarea class='textarea5'
name='description[]' id='description"+i+"'></textarea>";
cell1.innerHTML="<input style='width:69px'
type='text' name='qty[]' id='qty_"+i+"' onfocus='return B("+i+");' />";
cell3.innerHTML="<input style='width:50px'
type='text' name='rates[]' id='rates_"+i+"'/>";
cell4.innerHTML="<input style='width:80px' type='text'
readonly='readonly' name='amt[]' id='amt_"+i+"'
onfocus='return B("+i+");' onMouseOver='return B("+i+");' />";
}
</script>
我想用这个选择cell6.innerHTML=
代替input type="text"
?
<select class="select10" name="itemcode[]" id="itemcode"
style="width:150px;" onChange="getComboB(this)">
<option value="0"><--Select--> </option>
<?php
$query=mysql_query("SELECT * from products order by id");
while($row=mysql_fetch_assoc($query))
{
$val2=$row['itemcode'];
?>
<option value="<?=$val2;?>" <? if ($_GET['itemcode'] == $val2)
{ echo "selected='selected'"; }?>>
<?=$row['itemcode'];?>
</option>
<?php }?>
</select>
现在我添加了这段代码而不是input type text
oncell6.innerHTML=
但问题是new table row is not displaying?
cell6.innerHTML= '
<select class="select10" name="itemcode[]" id="itemcode"
style="width:150px;" onChange="getComboB(this)">
<option value="0"><--Select--> </option>
<?php
$query=mysql_query("SELECT * from products order by id");
while($row=mysql_fetch_assoc($query))
{
$val2=$row["itemcode"];
?>
<option value="<?=$val2;?>" <? if ($_GET['itemcode'] == $val2)
{ echo "selected=\"selected\""; }?>>
<?=$row["itemcode"];?>
</option>
<?php }?>
</select>';