【发布时间】:2016-10-12 01:43:23
【问题描述】:
我有 4 组未选中的单选按钮呈现给用户。然后,用户需要为每个组检查一个单选按钮。当我提交这个表单时,我得到的错误是,例如,对于picture_6.tif,传递的值是NULL。
我正在使用 CodeIgniter,并且表单正在通过 POST 提交。 我想知道你能不能告诉我我做错了什么。
<form action="/log" method="post" accept-charset="utf-8">
<table class="static">
<tbody>
<tr>
<td><input type="radio" name="picture_6.tif" value="0" class=""></td>
<td><input type="radio" name="picture_7.tif" value="0" class=""></td>
<td><input type="radio" name="picture_8.tif" value="0" class=""></td>
<td><input type="radio" name="picture_9.tif" value="0" class=""></td>
</tr>
<tr>
<td><input type="radio" name="picture_6.tif" value="1" class=""></td>
<td><input type="radio" name="picture_7.tif" value="1" class=""></td>
<td><input type="radio" name="picture_8.tif" value="1" class=""></td>
<td><input type="radio" name="picture_9.tif" value="1" class=""></td>
</tr>
<tr>
<td><input type="radio" name="picture_6.tif" value="2" class=""></td>
<td><input type="radio" name="picture_7.tif" value="2" class=""></td>
<td><input type="radio" name="picture_8.tif" value="2" class=""></td>
<td><input type="radio" name="picture_9.tif" value="2" class=""></td>
</tr>
<tr>
<td><input type="radio" name="picture_6.tif" value="3" class=""></td>
<td><input type="radio" name="picture_7.tif" value="3" class=""></td>
<td><input type="radio" name="picture_8.tif" value="3" class=""></td>
<td><input type="radio" name="picture_9.tif" value="3" class=""></td>
</tr>
<tr>
<td><input type="radio" name="picture_6.tif" value="9" class=""></td>
<td><input type="radio" name="picture_7.tif" value="9" class=""></td>
<td><input type="radio" name="picture_8.tif" value="9" class=""></td>
<td><input type="radio" name="picture_9.tif" value="9" class=""></td>
</tr>
</tbody>
<tbody>
<tr>
<td>
<div>
<input type="submit" name="mysubmit" value="Submit Post!">
</div>
</td>
</tr>
</tbody>
</table>
</form>
编辑:只需添加它以使其更易于搜索。该错误源于在 name 属性中使用句点。
【问题讨论】:
-
如果用户必须为每个组检查一个按钮,那么您需要更改每个组的命名。您对所有人都使用相同的
-
但是我将如何提供我需要的选项?例如,对于
picture_6.tif组,用户需要从其中一个单选按钮中进行选择(每个按钮都有不同的值)。其他组也一样。除非我遗漏了什么,否则更改名称不会提供该功能。 -
将
value="0"解释为null时出现问题,所以我们需要查看PHP 以找到确切原因 -
value
0在 HTML 视图页面中被硬编码;更改为另一个值会导致相同的错误 -
等等,现在我问你一个问题,如果第一组选择了picture_6.tif,第二组可以选择吗
标签: php html forms codeigniter radio-button