J
jadams
Hi
I have a form with a number of radio buttons on it eg.
<input type="radio" name="a1" value="1">
<input type="radio" name="a1" value="2">
<input type="radio" name="a1" value="3">
<input type="radio" name="a1" value="4">
<input type="radio" name="a1" value="5">
<input type="radio" name="a2" value="1">
<input type="radio" name="a2" value="2">
<input type="radio" name="a2" value="3">
<input type="radio" name="a2" value="4">
<input type="radio" name="a2" value="5">
when i submit the form the following function is performed, but it does
not work
all i want to check is that one(any) of the options is selected from
group a1 and one(any) of the options is selected from group a2 (on my
real form there are 40 groups !
required operation
loop through all groups a1 to a40
check to see if any of the 5 options for each group has been
selected
if yes - all is ok
remember which group has missed
end loop
inform user of all missed groups
1. I think that i am adding the counter "C" to the name of the radio
button wrong?
2. how do i add the "or" to check if a1 or a2 or a3 or a4 or a5 missing
then inform user?
this is my sample code
<!--Form Validation-->
<script type="text/javascript">
<!-- Begin
function checkFields() {
missinganswer = "";
for (c = 0; c < 40; c++) {
for (i = 0; i < 5; i++) {
if (document.feedbackadd.a & c.checked==false) {
missinganswer += "\n - Question:" + i;
}
}
}
if (missinganswer != "") {
missinganswer = "Please answer the following questions:\n" +
"_____________________________\n" +
missinganswer +
"\n_____________________________";
alert(missinganswer);
return false;
}
else return true;
}
// End -->
</script>
I have a form with a number of radio buttons on it eg.
<input type="radio" name="a1" value="1">
<input type="radio" name="a1" value="2">
<input type="radio" name="a1" value="3">
<input type="radio" name="a1" value="4">
<input type="radio" name="a1" value="5">
<input type="radio" name="a2" value="1">
<input type="radio" name="a2" value="2">
<input type="radio" name="a2" value="3">
<input type="radio" name="a2" value="4">
<input type="radio" name="a2" value="5">
when i submit the form the following function is performed, but it does
not work
all i want to check is that one(any) of the options is selected from
group a1 and one(any) of the options is selected from group a2 (on my
real form there are 40 groups !
required operation
loop through all groups a1 to a40
check to see if any of the 5 options for each group has been
selected
if yes - all is ok
remember which group has missed
end loop
inform user of all missed groups
1. I think that i am adding the counter "C" to the name of the radio
button wrong?
2. how do i add the "or" to check if a1 or a2 or a3 or a4 or a5 missing
then inform user?
this is my sample code
<!--Form Validation-->
<script type="text/javascript">
<!-- Begin
function checkFields() {
missinganswer = "";
for (c = 0; c < 40; c++) {
for (i = 0; i < 5; i++) {
if (document.feedbackadd.a & c.checked==false) {
missinganswer += "\n - Question:" + i;
}
}
}
if (missinganswer != "") {
missinganswer = "Please answer the following questions:\n" +
"_____________________________\n" +
missinganswer +
"\n_____________________________";
alert(missinganswer);
return false;
}
else return true;
}
// End -->
</script>