【发布时间】:2014-07-11 12:30:42
【问题描述】:
我正在研究 jquery 来发布输入表。所有输入都需要与其索引一起发布。我猜我不能使用输入元素的 id 或类来发布带有单元格位置信息的值。 .因为输入表是根据用户回答动态生成的。
例如;
用户在问题中输入“4”值并生成一个 3col 4row 输入表。
<table>
<tr><td><input type="text"></td> <td><input type="text"></td> <td><input type="text"></td>
</tr>
<tr><td><input type="text"></td> <td><input type="text"></td> <td><input type="text"></td>
</tr>
<tr><td><input type="text"></td> <td><input type="text"></td> <td><input type="text"></td>
</tr>
<tr><td><input type="text"></td> <td><input type="text"></td> <td><input type="text"></td>
</tr>
</table>
通过使用 jquery 处理程序,我可以存储值...
$(function () {
$("input").change(function() {
// save this.value() in an array.
array.push(this.value());
});
});
我停留在这一刻,因为我必须在表中存储带有 (x,y) 索引的值。不久;此二维表的值必须转换为 2dim。服务器端的数据数组。
类似...
$(function () {
$("input").change(function() {
array[this.col][this.row] = this.value();
});
});
总结一下;
是否可以获取表格内元素的位置(列,行)?
【问题讨论】:
标签: php jquery html arrays post