提交表单时,我的最后一行表输入未提交请求,我无法弄清楚原因。最后一行是由JavaScript函数生成的,但是我可以看到值的一面没有区别。其他的值将加载页面。
<tr>
<td>1</td>
<td><input name="companyid1" id="companyid1" size="5" value="1001"></td>
<td><input name="files1" id="files1" size="80" value="something.txt"></td>
<td><input name="check_dont_delete1" id="check_dont_delete1" type="checkbox"></td>
</tr>
<tr>
<td>2</td>
<td><input name="companyid2" id="companyid2" size="5" value="1001"></td>
<td><input name="files2" id="files2" size="80" value="junk.txt"></td>
<td><input name="check_dont_delete2" id="check_dont_delete2" type="checkbox"></td>
</tr>
<tr>
<td>3</td>
<td><input name="companyid3" id="companyid3" size="5"></td>
<td><input name="files3" id="files3" size="80"></td>
<td><input name="check_dont_delete3" id="check_dont_delete3" type="checkbox"></td>
</tr>
在Chrome开发者工具网络标签中,我正在查看表单数据但找不到它。
它将提交以前的所有内容,但不会提交动态添加的内容。
以下是来自具有此信息的请求的表单数据:
表单数据:
companyid1:1001
文件下载1:something.txt
companyid2:1001
files2:junk.txt
JavaScript功能:
function addRowToTable() {
var tbl = document.getElementById('destinations');
var lastRow = tbl.rows.length;
// if there's no header row in the table, then iteration = lastRow + 1
var iteration = lastRow;
var row = tbl.insertRow(lastRow);
// left cell
var cellLeft = row.insertCell(0);
var textNode = document.createTextNode(iteration);
cellLeft.appendChild(textNode);
// right cell
var cellRight = row.insertCell(1);
var el = document.createElement('input');
el.name = 'companyid' + iteration;
el.id = 'companyid' + iteration;
el.size = 5;
cellRight.appendChild(el);
// select cell
var cellRightSel = row.insertCell(2);
var sel = document.createElement('input');
sel.name = 'files' + iteration;
sel.id = 'files' + iteration;
sel.size = 80;
cellRightSel.appendChild(sel);
// select cell
var cellRightcheck = row.insertCell(3);
var selc = document.createElement('input');
selc.name = 'check_dont_delete' + iteration;
selc.id = 'check_dont_delete' + iteration;
selc.type = 'checkbox';
cellRightcheck.appendChild(selc);
}
表格&amp;提交:
<form method="post" class="form" action="new_edit.php?id=1" name="add_edit" id="update__form">
<button type="submit" class="btn btn-bl" name="update">Update</button
注意:这是我试图为我加入的新项目调试的遗留代码。