我尝试设置输入字段将是自定义的,因此如果客户需要,他可以根据需要添加输入字段 N 个数字,或者他可以根据需要将其删除,添加输入字段已实现但我无法获取文本字段的值,例如那n个数字
<tr>
<th>S.No</th>
<th>Description of Items</th>
<th>Quantity</th>
<th></th>
</tr>
<tr>
<td>
/td>
<td>
</td>
<td>
</td>
<td>
</td>
</tr>
</table>
<div>
<input type="button" onclick="AddRow('epcgCon')" value="ADD ROW" />
</div>
<div>
<input type="button" onclick="Submit()" value="Submit" />
</div>
我的 Javascript 是
var count = "1";
function AddRow(in_tbl_name) {
var tbody = document.getElementById(in_tbl_name).getElementsByTagName("TBODY")[0];
// create row
var row = document.createElement("TR");
// create table cell 2
var td1 = document.createElement("TD")
var strHtml2 = "" + count;
td1.innerHTML = strHtml2.replace(/!count!/g, count);
// create table cell 3
var td2 = document.createElement("TD")
var strHtml3 = "<input type=\"text\" name=\"Descr\" />";
td2.innerHTML = strHtml3.replace(/!count!/g, count);
// create table cell 4
var td3 = document.createElement("TD")
var strHtml4 = "<input type=\"text\" name=\"Qty\" />";
td3.innerHTML = strHtml4.replace(/!count!/g, count);
// create table cell 5
var td4 = document.createElement("TD")
var strHtml5 = "<input type=\"button\" value=\"Remove\" onClick=\"delRow()\"/>";
td4.innerHTML = strHtml5.replace(/!count!/g, count);
row.appendChild(td1);
row.appendChild(td2);
row.appendChild(td3);
row.appendChild(td4);
// add to count variable
count = parseInt(count) + 1;
// append row to table
tbody.appendChild(row);
}
function delRow() {
var current = window.event.srcElement;
//here we will delete the line
while ((current = current.parentElement) && current.tagName != "TR");
//Delete Row END
current.parentElement.removeChild(current);
}
我希望我在 n 次从 ajax 和 webservice 方法调用的数据库存储但我实际上需要如何在数组中获取这些值 n 次。
相关分类