我正在尝试以递归方式在表中创建带有表单元素的表。因此,为了使用文本输入填充所有JavasScript,我使用了JavasScript。我一直在尝试使文本输入实际上对应于将结果发布到新页面上的提交按钮。我该怎么做?
var rQty = parseInt(prompt("Number of Rows"), 10);
var cQty = parseInt(prompt("Number of Columns"), 10);
var table = document.getElementById("xTable");
for (let i = 0; i < rQty; i++) {
var row = table.insertRow();
for (let j = 0; j < cQty; j++) {
var cell = row.insertCell();
var input = document.createElement('input');
input.type = 'text';
input.name = 'input_r' + i + '-c' + j;
//I'm so tired while I'm writing this I can't remember which
//(name/id) POST method takes. mah bad
input.id = "a" + j
input.name = "a" + j
cell.appendChild(input);
}
}
* {
background-color: black;
color:white;
}
td {
border: 2px ridge white;
text-align: center;
color: white;
}
<center><table id="xTable">
<tr>
<td>
<form method="POST"
action="https://www.willmargulies.com/hwc.php">
<input type="submit">
</form>
</td>
</tr>
</table>
</center>
对不起,如果一切都很混乱/没有意义