<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>