golfer
04-02-2003, 07:27 PM
I have a dynamically generated form (from a database) which lists out skill sets in select drop-downs grouped by category.
The user can select one or more skill sets from any of the select boxes.
Here is a sample of what it looks like in code.
Category 1
<select name="SubCatID" multiple>
<option value="1">subcat 1
<option value="2">subcat 2
<option value="3">subcat 3
</select>
Category 2
<select name="SubCatID" multiple>
<option value="4">subcat 4
<option value="5">subcat 5
</select>
Notice that the "name" of each select is the same and that the value of each option is never duplicated in the different drop-downs.
My problem is that the user must choose at least ONE skill set. The code I am using is great if you have only 1 select, but it doesn't seem to be working if you have more than one select with the same name.
Here is my code:
for (i=0; i<=(SkillListLen - 1); i++)
{
if (form.SubCatID[i].selected)
{
SkillSelectProceed = 1;
break;
}
}
if (SkillSelectProceed == 0)
{
submitform = false;
manfields += "You must select at least one skill or expertise.\n";
}
The error I am getting is that form.SubCatID is not defined.
What do I have to change to either my form or the javascript validation to get this to work?
Thanks in advance.
Cheryl
The user can select one or more skill sets from any of the select boxes.
Here is a sample of what it looks like in code.
Category 1
<select name="SubCatID" multiple>
<option value="1">subcat 1
<option value="2">subcat 2
<option value="3">subcat 3
</select>
Category 2
<select name="SubCatID" multiple>
<option value="4">subcat 4
<option value="5">subcat 5
</select>
Notice that the "name" of each select is the same and that the value of each option is never duplicated in the different drop-downs.
My problem is that the user must choose at least ONE skill set. The code I am using is great if you have only 1 select, but it doesn't seem to be working if you have more than one select with the same name.
Here is my code:
for (i=0; i<=(SkillListLen - 1); i++)
{
if (form.SubCatID[i].selected)
{
SkillSelectProceed = 1;
break;
}
}
if (SkillSelectProceed == 0)
{
submitform = false;
manfields += "You must select at least one skill or expertise.\n";
}
The error I am getting is that form.SubCatID is not defined.
What do I have to change to either my form or the javascript validation to get this to work?
Thanks in advance.
Cheryl