我在这里有动态添加文本框的 JS 代码。我想添加另一个删除这些文本框的按钮,以防意外单击添加按钮。谢谢!
<script language="javascript">
row_no=0;
function addRow(tbl,row){
row_no++;
if (row_no<=20){
if (row_no<=20){
if (row_no>=10){
var textbox = row_no+'.) <input type="text" size = "50" maxlength= "50" name= "desk_user[]">';
}
if (row_no<10){
var textbox = row_no+'. ) <input type="text" size = "20" maxlength= "50" name= "desk_user[]">';
}
var textbox2 = '<input type="text" size = "60" maxlength= "250" name= "desk_report[]">';
var textbox3 = '<input type="text" size = "60" maxlength= "250" name= "desk_action[]">';
var tbl = document.getElementById(tbl);
var rowIndex = document.getElementById(row).value;
var newRow = tbl.insertRow(row_no);
var newCell = newRow.insertCell(0);
newCell.innerHTML = textbox;
var newCell = newRow.insertCell(1);
newCell.innerHTML = textbox2;
var newCell = newRow.insertCell(2);
newCell.innerHTML = textbox3;
}
if (row_no>20){
alert ("Too Many Items. Limit of 20.");
}
}
}
</script>