如何使用PHP post方法提交复选框值 [英] How to submit checkbox values with PHP post method
本文介绍了如何使用PHP post方法提交复选框值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<input type="checkbox" class='form' name="checkbox_1" />
<input type="checkbox" class='form' name="checkbox_2" />
<input type="checkbox" class='form' name="checkbox_3" />
.........
<input type="checkbox" class='form' name="checkbox_10" />
发件人已使用"POST"方法提交.确定哪个复选框,并以递增的顺序写入其编号.用空格(不是换行)分隔所有数字,并且不使用任何HTML格式.
The from has been submitted using the "POST" method. identify, which of the check-boxes and write their numbers in increasing order. Separated all numbers by spaces(not new lines) and do not use any HTML formatting.
例如:
如果选中了复选框3、5和10.
If check-boxes 3, 5 and 10 are checked.
输出应该是:
3 5 10
推荐答案
将标记更改为类似
<input type="checkbox" class='form' value="1" name="checkbox[]" />
<input type="checkbox" class='form' value="2" name="checkbox[]" />
<input type="checkbox" class='form' value="3" name="checkbox[]" />
并通过简单循环
foreach($_POST['checkbox'] as $checkbox){
echo $checkbox . ' ';
}
这篇关于如何使用PHP post方法提交复选框值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文