V
Vancouver
Hi there,
I have 24 radio button groups, and 7 options for each group. I wrote
code below trying to see if each radio button group is checked. But it
does not work. Any help? Thanks.
(24 radio button groups are named question[0] to question[23].
choices[] is to store true/false)
<script type="text/JavaScript">
function ifChecked()
{
var choices=new Array();
for (index=0;index<24;index++)
{
choices[index]=false;
for (i=0;i<7;i++)
{
if (document.forms[0].question[index].checked)
{
choices[index]=true;
break;
}
}
}
for (index=0;index<24;index++)
{
if (!choices[index])
{
alert ("Please make a selection");
return false;
}
}
return true;
}
</script>
I have 24 radio button groups, and 7 options for each group. I wrote
code below trying to see if each radio button group is checked. But it
does not work. Any help? Thanks.
(24 radio button groups are named question[0] to question[23].
choices[] is to store true/false)
<script type="text/JavaScript">
function ifChecked()
{
var choices=new Array();
for (index=0;index<24;index++)
{
choices[index]=false;
for (i=0;i<7;i++)
{
if (document.forms[0].question[index].checked)
{
choices[index]=true;
break;
}
}
}
for (index=0;index<24;index++)
{
if (!choices[index])
{
alert ("Please make a selection");
return false;
}
}
return true;
}
</script>