牛骨文教育服务平台(让学习变的简单)
博文笔记

Form表单传递数组

创建时间:2011-03-13 投稿人: 浏览次数:174

对于一个问题的多个答案,如果我们可以通过form表单传递数组,那程序处理起来会简单多了:

<table>
<tr>
<td><input type="checkbox" name="how_hear[]" id="how_hear1" value="Website" ></td>
<td style="padding-left:3px"><label for="how_hear1">Website</label></td>
</tr>
<tr>
<td><input type="checkbox" name="how_hear[]" id="how_hear2" value="TV Commercial" /></td>
<td style="padding-left:3px"><label for="how_hear2">TV Commercial</label></td>
</tr>
<tr>
<td><input type="checkbox" name="how_hear[]" id="how_hear3" value="Magazine Ad" /></td>
<td style="padding-left:3px"><label for="how_hear3">Magazine Ad</label></td>
</tr>
</table>
"[]"表示这个变量是一个数组,如果是PHP的话,可以这样获得这个数组$_POST["how_hear"]。
声明:该文观点仅代表作者本人,牛骨文系教育信息发布平台,牛骨文仅提供信息存储空间服务。