因为我还在尝试解决我的另一个问题(这里需要一些帮助!),我正在探索如何命名相同但不同行的表单元素.
下面这个例子在这里,文章的作者叫他的文本框是"input_box_one".他编写的jQuery函数也复制了输入框以具有相同的名称.我想知道命名这样的文本框的原因,以及他要编写的服务器脚本如何从类似命名的文本框中收集输入?
我将用Classic ASP写作.
<table id = "options-table">
<tr>
<td>Input-Box-One</td>
<td>Input-Box-Two</td>
<td> </td>
</tr>
<tr>
<td><input type = "text" name = "input_box_one[]" /></td>
<td><input type = "text" name = "input_box_two[]" /></td>
<td><input type = "button" class = "del" value = "Delete" /></td>
</tr>
<tr>
<td><input type = "text" name = "input_box_one[]" /></td>
<td><input type = "text" name = "input_box_two[]" /></td>
<td><input type = "button" class = "add" value = "Add More" /></td>
</tr>
</table>
Run Code Online (Sandbox Code Playgroud)
谢谢!
在ASP Classic中,Request.Form("someName")返回实现IStringList接口的对象.此接口有两个成员Item([i]]),它们是默认属性Count.
如果要发布到ASP,则应删除[]后缀.您可以使用其他索引器参数访问使用相同名称的多个值i.例如
Dim someValue : someValue = Request.Form("someName")(2)
Run Code Online (Sandbox Code Playgroud)
我不记得这个集合是基于0还是1,但你应该很容易测试.该对象也可以支持For Each,但在您的场景中可能没有用.