我有类似以下内容的HTML表输入的重复行:如何引用表格单元格中的输入值进行循环验证?
<table id="tableInput">
<thead>
<tr>
<th>Col 1</th>
<th>Col 2</th>
</tr>
</thead>
<tbody id='abc'>
<tr>
<td><input id="itemid" name="itemid" type="text" size="20" /></td>
<td>Col2 desc</td>
</tr>
<tr>
<td><input id="itemid" name="itemid" type="text" size="20" /></td>
<td>Col2 desc</td>
</tr>
</tbody>
</table>
我如何可以参考输入的ID在确认循环?例如:
i=0;
while i < document.getElementById("tableInput").tBodies.length {
x = document.getElementById("tableInput").tBodies[i].input.value);
if x = "" {
errorMsg = 1;
}
i++;
}
每个“”的“id”属性应该是唯一的。 – 2014-10-31 23:02:03
这是一个伪代码还是一种方言,或者您是否忘记了条件周围的“(...)”? – 2014-10-31 23:02:25
“FormElement.elements”集合将包含一个Array Like Object,如果您使用的是“ID”,则您可以循环搜索“