用PHP处理多个同名复选框
<script language="javascript">
function check()
{
var strchoice="";
for(var i=0;i<document.news.choice.length;i++)
{
if (document.news.choice[i].checked)
{
strchoice=strchoice+document.news.choice[i].value+",";
}
}
if (!document.news.choice.length)
{
if (document.news.choice.checked)
{
strchoice=document.news.choice[i].value;+","
}
}
strchoice=strchoice.substring(0,strchoice.length-1);
document.news.choiceid.value=strchoice;
alert(document.news.choiceall.value);
}
</script>
<html>
...
<form name="news" action="test.php" method="post" onsubmit="check()">
<input type="checkbox" name="choice" value="1">
<input type="checkbox" name="choice" value="2">
<input type="checkbox" name="choice" value="3">
<input type="checkbox" name="choice" value="4">
<input type="hidden" name="choiceid" value="">
</form>
...
</html>
- 上一篇: PHP中的正规表达式
- 下一篇: PHP如何统计在线人数