读书人

有关checkbox的有关问题

发布时间: 2012-06-23 14:52:43 作者: rapoo

有关checkbox的问题?
这样定义两个复选框:
<input type="checkbox" name="xuanze[]" id="xuanze[]" value="1"checked>
<input type="checkbox" name="xuanze[]" id="xuanze[]" value="2"checked>
怎样取得它们的value值?
我试过这种取法:$_POST['xuanze'][0],$_POST['xuanze'][1],结果失败了,请问谁知道怎么取得?

[解决办法]
在此我非常抱歉,那段代码没测试,我有测试了一下,是这样:

PHP code
<?phpif(isset($_POST)){    print_r($_POST);    #Array ( [id] => Array ( [0] => 3 [1] => 4 ) [del] => 删除 )#也就是说,name中[]会被解析为0,1……#$_POST['id'][0] => 3}?><form id="form3" name="form3" method="post" action="test18.php">  <p>  <label for="id2">删除序号为</label>  <input name="id[]" type="text" id="id2" size="10" value="3" />  <input name="id[]" type="text" id="id2" size="10" value="3" />  的记录  </p>  <p>  <input type="submit" name="del" id="del" value="删除" />  </p></form> 

读书人网 >PHP

热点推荐