javascript——自动添加行

来源:互联网 发布:巧克力 日本 知乎 编辑:程序博客网 时间:2024/05/02 03:42
<form action="product.action" method="post">
    <table id="tab">
<tr>
<td>
<input type="text" name="products">
<input type="button" name="button" value="增加" onclick="insertRow()">
</td>
</tr>
<tr>
<td bgcolor="#FFFF66">
<input name="submit" type="submit" value="批量增加"/>
</td>
</tr>
</table>
</form>




<script type="text/javascript">
function insertRow(){
var myTab=document.getElementById("tab");
var newRow=myTab.insertRow(myTab.rows.length-1);
newRow.insertCell(0).innerHTML="<tr><td><input type=\"text\" name=\"products\"/></td></tr>";
}
</script>
  
原创粉丝点击