Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Validating group of Listboxes plus textboxes....complicated

Status
Not open for further replies.

Gulluman

Technical User
Feb 23, 2006
2
CA
Hi,

I have a group of 24 list boxes plus 24 text boxes. I have two groups like this. The user will choose from each list boxes and enter a 3 digit number beside it. The user can choose minimum of 4 items and enter the digits in the corresponding text boxes. The user can choose any 4 out of 24 choices.

Validation : The form will not be submitted without choosing at least 4 list boxes along with filled text boxes.

I would really appreciate if someone could help.
The code is given below.

Thanks in advance.

Gulluman.

-----------------
<HTML>
<HEAD>
<TITLE>Test Form</TITLE>
</HEAD>
<FORM name="course_approval_form" method="POST" action=" onsubmit="validate();">
<H1><CENTER><FONT COLOR="#000000">B.Sc Course Approval Form</FONT>
</CENTER></H1>
<H3><CENTER>
<INPUT TYPE="hidden" NAME="your_email_address" VALUE="amiasof@30gigs.com">
<INPUT TYPE="hidden" NAME="your_name" VALUE="Webmaster">
<INPUT TYPE="hidden" NAME="email_subject_line" VALUE="B.Sc Course Approval">
<INPUT TYPE="hidden" NAME="required_fields" VALUE="your_email_address">
<INPUT TYPE="hidden" NAME="thank_you_title" VALUE="B.Sc">
<INPUT TYPE="hidden" NAME="return_link_url" VALUE="<INPUT TYPE="hidden" NAME="return_link_name" VALUE="Back To msn">
<INPUT TYPE="hidden" NAME="background_color" VALUE="#C0C0C0">
<INPUT TYPE="hidden" NAME="text_color" VALUE="#000000">
<INPUT TYPE="hidden" NAME="link_color" VALUE="#0000FF">
<INPUT TYPE="hidden" NAME="visited_link_color" VALUE="#8000FF">
<INPUT TYPE="hidden" NAME="active_link_color" VALUE="#0000FF">
</CENTER></H3>

<H3><CENTER>Test</CENTER></H3>
<P><CENTER>Just complete this form. Click on Submit when ready to

send.</CENTER></P>

<br />


<table BORDER="3" align='center' >
<tr BGCOLOR="#87CEFA">
<td valign="top" >
&nbsp&nbsp&nbsp Humanities &nbsp&nbsp&nbsp </td>
<td valign="top" > &nbsp Social Science &nbsp </td>
<td valign="top" > &nbsp&nbsp&nbsp Language &nbsp&nbsp&nbsp </td>
<td valign="top" >&nbsp Math/Science &nbsp </td>
</tr>
<tr>
<td valign="top" >
<SELECT SIZE="1" NAME="humanities">
<OPTION VALUE="ARTH" selected>ARTH</OPTION>
<OPTION VALUE="CANS">CANS</OPTION>
<OPTION VALUE="CATH">CATH</OPTION>

<OPTION VALUE="WMST">WMST</OPTION>
</SELECT>
<INPUT TYPE="text" NAME="HumCourseNo" VALUE="" SIZE=3 maxlength=3 onKeypress="if ((event.keyCode > 31 && event.keyCode < 48) || (event.keyCode > 57 && event.keyCode < 127)) event.returnValue = false; else return noenter()"></td>
<td valign="top" >
<SELECT SIZE="1" NAME="SocialSciences">
<OPTION VALUE="ANTH" selected>ANTH</OPTION>
<OPTION VALUE="CANS">CANS</OPTION>

</SELECT>
<INPUT TYPE="text" NAME="SocSciCourseNo" VALUE="" SIZE=3 maxlength=3 onKeypress="if ((event.keyCode > 31 && event.keyCode < 48) || (event.keyCode > 57 && event.keyCode < 127)) event.returnValue = false; else return noenter()"> </td>
<td valign="top" >
<SELECT SIZE="1" NAME="Languages">
<OPTION VALUE="CLAS" selected>CLAS</OPTION>
<OPTION VALUE="EAST">EAST</OPTION>

</SELECT>
<INPUT TYPE="text" NAME="LangCourseNo" VALUE="" SIZE=3 maxlength=3 onKeypress="if ((event.keyCode > 31 && event.keyCode < 48) || (event.keyCode > 57 && event.keyCode < 127)) event.returnValue = false; else return noenter()">
</td>
<td valign="top" >
<SELECT SIZE="1" NAME="Maths-Sci">
<OPTION VALUE="ATOC" selected>ATOC</OPTION>
<OPTION VALUE="BIOL">BIOL</OPTION>
<OPTION VALUE="CHEM">CHEM</OPTION>

</SELECT>
<INPUT TYPE="text" NAME="HumCourseNo" VALUE="" SIZE=3 maxlength=3 onKeypress="if ((event.keyCode > 31 && event.keyCode < 48) || (event.keyCode > 57 && event.keyCode < 127)) event.returnValue = false; else return noenter()"> </td>
</tr>
<tr>
<td valign="top" >
<SELECT SIZE="1" NAME="humanities">
<OPTION VALUE="ARTH" selected>ARTH</OPTION>
<OPTION VALUE="CANS">CANS</OPTION>
<OPTION VALUE="CATH">CATH</OPTION>

</SELECT>
<INPUT TYPE="text" NAME="HumCourseNo" VALUE="" SIZE=3 maxlength=3 onKeypress="if ((event.keyCode > 31 && event.keyCode < 48) || (event.keyCode > 57 && event.keyCode < 127)) event.returnValue = false; else return noenter()"></td>
<td valign="top" >
<SELECT SIZE="1" NAME="SocialSciences">
<OPTION VALUE="ANTH" selected>ANTH</OPTION>
<OPTION VALUE="CANS">CANS</OPTION>
<OPTION VALUE="CATH">CATH</OPTION>

</SELECT>
<INPUT TYPE="text" NAME="SocSciCourseNo" VALUE="" SIZE=3 maxlength=3 onKeypress="if ((event.keyCode > 31 && event.keyCode < 48) || (event.keyCode > 57 && event.keyCode < 127)) event.returnValue = false; else return noenter()"> </td>
<td valign="top" >
<SELECT SIZE="1" NAME="Languages">
<OPTION VALUE="CLAS" selected>CLAS</OPTION>
<OPTION VALUE="CANS">CANS</OPTION>
<OPTION VALUE="CATH">CATH</OPTION>

</SELECT>
<INPUT TYPE="text" NAME="LangCourseNo" VALUE="" SIZE=3 maxlength=3 onKeypress="if ((event.keyCode > 31 && event.keyCode < 48) || (event.keyCode > 57 && event.keyCode < 127)) event.returnValue = false; else return noenter()">
</td>
<td valign="top" >
<SELECT SIZE="1" NAME="Maths-Sci">
<OPTION VALUE="ATOC" selected>ATOC</OPTION>
<OPTION VALUE="CANS">CANS</OPTION>
<OPTION VALUE="CATH">CATH</OPTION>
<OPTION VALUE="CLAS">CLAS</OPTION>

</SELECT>
<INPUT TYPE="text" NAME="HumCourseNo" VALUE="" SIZE=3 maxlength=3 onKeypress="if ((event.keyCode > 31 && event.keyCode < 48) || (event.keyCode > 57 && event.keyCode < 127)) event.returnValue = false; else return noenter()"> </td>
</tr>
<tr>
<td valign="top" >
<SELECT SIZE="1" NAME="humanities">
<OPTION VALUE="ARTH" selected>ARTH</OPTION>
<OPTION VALUE="CANS">CANS</OPTION>
<OPTION VALUE="CATH">CATH</OPTION>

</SELECT>
<INPUT TYPE="text" NAME="HumCourseNo" VALUE="" SIZE=3 maxlength=3 onKeypress="if ((event.keyCode > 31 && event.keyCode < 48) || (event.keyCode > 57 && event.keyCode < 127)) event.returnValue = false; else return noenter()"></td>
<td valign="top" >
<SELECT SIZE="1" NAME="SocialSciences">
<OPTION VALUE="ANTH" selected>ANTH</OPTION>
<OPTION VALUE="CANS">CANS</OPTION>
<OPTION VALUE="ECON">ECON</OPTION>

</SELECT>
<INPUT TYPE="text" NAME="SocSciCourseNo" VALUE="" SIZE=3 maxlength=3 onKeypress="if ((event.keyCode > 31 && event.keyCode < 48) || (event.keyCode > 57 && event.keyCode < 127)) event.returnValue = false; else return noenter()"> </td>
<td valign="top" >
<SELECT SIZE="1" NAME="Languages">
<OPTION VALUE="CLAS" selected>CLAS</OPTION>
<OPTION VALUE="EAST">EAST</OPTION>
<OPTION VALUE="ESLN">ESLN</OPTION>

</SELECT>
<INPUT TYPE="text" NAME="LangCourseNo" VALUE="" SIZE=3 maxlength=3 onKeypress="if ((event.keyCode > 31 && event.keyCode < 48) || (event.keyCode > 57 && event.keyCode < 127)) event.returnValue = false; else return noenter()">
</td>
<td valign="top" >
<SELECT SIZE="1" NAME="Maths-Sci">
<OPTION VALUE="ATOC" selected>ATOC</OPTION>
<OPTION VALUE="BIOL">BIOL</OPTION>
<OPTION VALUE="CHEM">CHEM</OPTION>

</SELECT>
<INPUT TYPE="text" NAME="HumCourseNo" VALUE="" SIZE=3 maxlength=3 onKeypress="if ((event.keyCode > 31 && event.keyCode < 48) || (event.keyCode > 57 && event.keyCode < 127)) event.returnValue = false; else return noenter()"> </td></tr>
<tr>
<td valign="top" >
<SELECT SIZE="1" NAME="humanities">
<OPTION VALUE="ARTH" selected>ARTH</OPTION>
<OPTION VALUE="CANS">CANS</OPTION>
<OPTION VALUE="CATH">CATH</OPTION>

</SELECT>
<INPUT TYPE="text" NAME="HumCourseNo" VALUE="" SIZE=3 maxlength=3 onKeypress="if ((event.keyCode > 31 && event.keyCode < 48) || (event.keyCode > 57 && event.keyCode < 127)) event.returnValue = false; else return noenter()"></td>
<td valign="top" >
<SELECT SIZE="1" NAME="SocialSciences">
<OPTION VALUE="ANTH" selected>ANTH</OPTION>
<OPTION VALUE="CANS">CANS</OPTION>

</SELECT>
<INPUT TYPE="text" NAME="SocSciCourseNo" VALUE="" SIZE=3 maxlength=3 onKeypress="if ((event.keyCode > 31 && event.keyCode < 48) || (event.keyCode > 57 && event.keyCode < 127)) event.returnValue = false; else return noenter()"> </td>
<td valign="top" >
<SELECT SIZE="1" NAME="Languages">
<OPTION VALUE="CLAS" selected>CLAS</OPTION>
<OPTION VALUE="EAST">EAST</OPTION>
<OPTION VALUE="ESLN">ESLN</OPTION>

</SELECT>
<INPUT TYPE="text" NAME="LangCourseNo" VALUE="" SIZE=3 maxlength=3 onKeypress="if ((event.keyCode > 31 && event.keyCode < 48) || (event.keyCode > 57 && event.keyCode < 127)) event.returnValue = false; else return noenter()">
</td>
<td valign="top" >
<SELECT SIZE="1" NAME="Maths-Sci">
<OPTION VALUE="ATOC" selected>ATOC</OPTION>
<OPTION VALUE="BIOL">BIOL</OPTION>
<OPTION VALUE="CHEM">CHEM</OPTION>

</SELECT>
<INPUT TYPE="text" NAME="HumCourseNo" VALUE="" SIZE=3 maxlength=3 onKeypress="if ((event.keyCode > 31 && event.keyCode < 48) || (event.keyCode > 57 && event.keyCode < 127)) event.returnValue = false; else return noenter()"> </td>
</tr>
<tr>
<td valign="top" >
<SELECT SIZE="1" NAME="humanities">
<OPTION VALUE="ARTH" selected>ARTH</OPTION>
<OPTION VALUE="CANS">CANS</OPTION>
<OPTION VALUE="CATH">CATH</OPTION>
<OPTION VALUE="CLAS">CLAS</OPTION>

</SELECT>
<INPUT TYPE="text" NAME="HumCourseNo" VALUE="" SIZE=3 maxlength=3 onKeypress="if ((event.keyCode > 31 && event.keyCode < 48) || (event.keyCode > 57 && event.keyCode < 127)) event.returnValue = false; else return noenter()"></td>
<td valign="top" >
<SELECT SIZE="1" NAME="SocialSciences">
<OPTION VALUE="ANTH" selected>ANTH</OPTION>
<OPTION VALUE="CANS">CANS</OPTION>
<OPTION VALUE="ECON">ECON</OPTION>

</SELECT>
<INPUT TYPE="text" NAME="SocSciCourseNo" VALUE="" SIZE=3 maxlength=3 onKeypress="if ((event.keyCode > 31 && event.keyCode < 48) || (event.keyCode > 57 && event.keyCode < 127)) event.returnValue = false; else return noenter()"> </td>
<td valign="top" >
<SELECT SIZE="1" NAME="Languages">
<OPTION VALUE="CLAS" selected>CLAS</OPTION>
<OPTION VALUE="EAST">EAST</OPTION>
<OPTION VALUE="ESLN">ESLN</OPTION>

</SELECT>
<INPUT TYPE="text" NAME="LangCourseNo" VALUE="" SIZE=3 maxlength=3 onKeypress="if ((event.keyCode > 31 && event.keyCode < 48) || (event.keyCode > 57 && event.keyCode < 127)) event.returnValue = false; else return noenter()">
</td>
<td valign="top" >
<SELECT SIZE="1" NAME="Maths-Sci">
<OPTION VALUE="ATOC" selected>ATOC</OPTION>
<OPTION VALUE="BIOL">BIOL</OPTION>
<OPTION VALUE="CHEM">CHEM</OPTION>

</SELECT>
<INPUT TYPE="text" NAME="HumCourseNo" VALUE="" SIZE=3 maxlength=3 onKeypress="if ((event.keyCode > 31 && event.keyCode < 48) || (event.keyCode > 57 && event.keyCode < 127)) event.returnValue = false; else return noenter()"> </td></tr>
<tr>
<td valign="top" >
<SELECT SIZE="1" NAME="humanities">
<OPTION VALUE="ARTH" selected>ARTH</OPTION>
<OPTION VALUE="CANS">CANS</OPTION>
<OPTION VALUE="CATH">CATH</OPTION>

</SELECT>
<INPUT TYPE="text" NAME="HumCourseNo" VALUE="" SIZE=3 maxlength=3 onKeypress="if ((event.keyCode > 31 && event.keyCode < 48) || (event.keyCode > 57 && event.keyCode < 127)) event.returnValue = false; else return noenter()"></td>
<td valign="top" >
<SELECT SIZE="1" NAME="SocialSciences">
<OPTION VALUE="ANTH" selected>ANTH</OPTION>
<OPTION VALUE="CANS">CANS</OPTION>
<OPTION VALUE="CATH">CATH</OPTION>

</SELECT>
<INPUT TYPE="text" NAME="SocSciCourseNo" VALUE="" SIZE=3 maxlength=3 onKeypress="if ((event.keyCode > 31 && event.keyCode < 48) || (event.keyCode > 57 && event.keyCode < 127)) event.returnValue = false; else return noenter()" > </td>
<td valign="top" >
<SELECT SIZE="1" NAME="Languages">
<OPTION VALUE="CLAS" selected>CLAS</OPTION>
<OPTION VALUE="CANS">CANS</OPTION>
<OPTION VALUE="CATH">CATH</OPTION>

</SELECT>
<INPUT TYPE="text" NAME="LangCourseNo" VALUE="" SIZE=3 maxlength=3 onKeypress="if ((event.keyCode > 31 && event.keyCode < 48) || (event.keyCode > 57 && event.keyCode < 127)) event.returnValue = false; else return noenter()">
</td>
<td valign="top" >
<SELECT SIZE="1" NAME="Maths-Sci">
<OPTION VALUE="ATOC" selected>ATOC</OPTION>
<OPTION VALUE="CANS">CANS</OPTION>

</SELECT>
<INPUT TYPE="text" NAME="HumCourseNo" VALUE="" SIZE=3 maxlength=3 onKeypress="if ((event.keyCode > 31 && event.keyCode < 48) || (event.keyCode > 57 && event.keyCode < 127)) event.returnValue = false; else return noenter()"> </td>
</tr>

</table><br /><br />

<table BORDER="3" align='center' >
<tr BGCOLOR="#87CEFA">
<td valign="top" >
&nbsp&nbsp&nbsp Humanities &nbsp&nbsp&nbsp </td>
<td valign="top" > &nbsp Social Science &nbsp </td>
<td valign="top" > &nbsp&nbsp&nbsp Language &nbsp&nbsp&nbsp </td>
<td valign="top" >&nbsp Math/Science &nbsp </td>
</tr>
<tr>
<td valign="top" >
<SELECT SIZE="1" NAME="humanities">
<OPTION VALUE="ARTH" selected>ARTH</OPTION>
<OPTION VALUE="CANS">CANS</OPTION>
<OPTION VALUE="CATH">CATH</OPTION>

<OPTION VALUE="WMST">WMST</OPTION>
</SELECT>
<INPUT TYPE="text" NAME="HumCourseNo" VALUE="" SIZE=3 maxlength=3 onKeypress="if ((event.keyCode > 31 && event.keyCode < 48) || (event.keyCode > 57 && event.keyCode < 127)) event.returnValue = false; else return noenter()"></td>
<td valign="top" >
<SELECT SIZE="1" NAME="SocialSciences">
<OPTION VALUE="ANTH" selected>ANTH</OPTION>
<OPTION VALUE="CANS">CANS</OPTION>

</SELECT>
<INPUT TYPE="text" NAME="SocSciCourseNo" VALUE="" SIZE=3 maxlength=3 onKeypress="if ((event.keyCode > 31 && event.keyCode < 48) || (event.keyCode > 57 && event.keyCode < 127)) event.returnValue = false; else return noenter()"> </td>
<td valign="top" >
<SELECT SIZE="1" NAME="Languages">
<OPTION VALUE="CLAS" selected>CLAS</OPTION>
<OPTION VALUE="EAST">EAST</OPTION>

</SELECT>
<INPUT TYPE="text" NAME="LangCourseNo" VALUE="" SIZE=3 maxlength=3 onKeypress="if ((event.keyCode > 31 && event.keyCode < 48) || (event.keyCode > 57 && event.keyCode < 127)) event.returnValue = false; else return noenter()">
</td>
<td valign="top" >
<SELECT SIZE="1" NAME="Maths-Sci">
<OPTION VALUE="ATOC" selected>ATOC</OPTION>
<OPTION VALUE="BIOL">BIOL</OPTION>
<OPTION VALUE="CHEM">CHEM</OPTION>

</SELECT>
<INPUT TYPE="text" NAME="HumCourseNo" VALUE="" SIZE=3 maxlength=3 onKeypress="if ((event.keyCode > 31 && event.keyCode < 48) || (event.keyCode > 57 && event.keyCode < 127)) event.returnValue = false; else return noenter()"> </td>
</tr>
<tr>
<td valign="top" >
<SELECT SIZE="1" NAME="humanities">
<OPTION VALUE="ARTH" selected>ARTH</OPTION>
<OPTION VALUE="CANS">CANS</OPTION>
<OPTION VALUE="CATH">CATH</OPTION>

</SELECT>
<INPUT TYPE="text" NAME="HumCourseNo" VALUE="" SIZE=3 maxlength=3 onKeypress="if ((event.keyCode > 31 && event.keyCode < 48) || (event.keyCode > 57 && event.keyCode < 127)) event.returnValue = false; else return noenter()"></td>
<td valign="top" >
<SELECT SIZE="1" NAME="SocialSciences">
<OPTION VALUE="ANTH" selected>ANTH</OPTION>
<OPTION VALUE="CANS">CANS</OPTION>
<OPTION VALUE="CATH">CATH</OPTION>

</SELECT>
<INPUT TYPE="text" NAME="SocSciCourseNo" VALUE="" SIZE=3 maxlength=3 onKeypress="if ((event.keyCode > 31 && event.keyCode < 48) || (event.keyCode > 57 && event.keyCode < 127)) event.returnValue = false; else return noenter()"> </td>
<td valign="top" >
<SELECT SIZE="1" NAME="Languages">
<OPTION VALUE="CLAS" selected>CLAS</OPTION>
<OPTION VALUE="CANS">CANS</OPTION>
<OPTION VALUE="CATH">CATH</OPTION>

</SELECT>
<INPUT TYPE="text" NAME="LangCourseNo" VALUE="" SIZE=3 maxlength=3 onKeypress="if ((event.keyCode > 31 && event.keyCode < 48) || (event.keyCode > 57 && event.keyCode < 127)) event.returnValue = false; else return noenter()">
</td>
<td valign="top" >
<SELECT SIZE="1" NAME="Maths-Sci">
<OPTION VALUE="ATOC" selected>ATOC</OPTION>
<OPTION VALUE="CANS">CANS</OPTION>
<OPTION VALUE="CATH">CATH</OPTION>
<OPTION VALUE="CLAS">CLAS</OPTION>

</SELECT>
<INPUT TYPE="text" NAME="HumCourseNo" VALUE="" SIZE=3 maxlength=3 onKeypress="if ((event.keyCode > 31 && event.keyCode < 48) || (event.keyCode > 57 && event.keyCode < 127)) event.returnValue = false; else return noenter()"> </td>
</tr>
<tr>
<td valign="top" >
<SELECT SIZE="1" NAME="humanities">
<OPTION VALUE="ARTH" selected>ARTH</OPTION>
<OPTION VALUE="CANS">CANS</OPTION>
<OPTION VALUE="CATH">CATH</OPTION>

</SELECT>
<INPUT TYPE="text" NAME="HumCourseNo" VALUE="" SIZE=3 maxlength=3 onKeypress="if ((event.keyCode > 31 && event.keyCode < 48) || (event.keyCode > 57 && event.keyCode < 127)) event.returnValue = false; else return noenter()"></td>
<td valign="top" >
<SELECT SIZE="1" NAME="SocialSciences">
<OPTION VALUE="ANTH" selected>ANTH</OPTION>
<OPTION VALUE="CANS">CANS</OPTION>
<OPTION VALUE="ECON">ECON</OPTION>

</SELECT>
<INPUT TYPE="text" NAME="SocSciCourseNo" VALUE="" SIZE=3 maxlength=3 onKeypress="if ((event.keyCode > 31 && event.keyCode < 48) || (event.keyCode > 57 && event.keyCode < 127)) event.returnValue = false; else return noenter()"> </td>
<td valign="top" >
<SELECT SIZE="1" NAME="Languages">
<OPTION VALUE="CLAS" selected>CLAS</OPTION>
<OPTION VALUE="EAST">EAST</OPTION>
<OPTION VALUE="ESLN">ESLN</OPTION>

</SELECT>
<INPUT TYPE="text" NAME="LangCourseNo" VALUE="" SIZE=3 maxlength=3 onKeypress="if ((event.keyCode > 31 && event.keyCode < 48) || (event.keyCode > 57 && event.keyCode < 127)) event.returnValue = false; else return noenter()">
</td>
<td valign="top" >
<SELECT SIZE="1" NAME="Maths-Sci">
<OPTION VALUE="ATOC" selected>ATOC</OPTION>
<OPTION VALUE="BIOL">BIOL</OPTION>
<OPTION VALUE="CHEM">CHEM</OPTION>

</SELECT>
<INPUT TYPE="text" NAME="HumCourseNo" VALUE="" SIZE=3 maxlength=3 onKeypress="if ((event.keyCode > 31 && event.keyCode < 48) || (event.keyCode > 57 && event.keyCode < 127)) event.returnValue = false; else return noenter()"> </td></tr>
<tr>
<td valign="top" >
<SELECT SIZE="1" NAME="humanities">
<OPTION VALUE="ARTH" selected>ARTH</OPTION>
<OPTION VALUE="CANS">CANS</OPTION>
<OPTION VALUE="CATH">CATH</OPTION>

</SELECT>
<INPUT TYPE="text" NAME="HumCourseNo" VALUE="" SIZE=3 maxlength=3 onKeypress="if ((event.keyCode > 31 && event.keyCode < 48) || (event.keyCode > 57 && event.keyCode < 127)) event.returnValue = false; else return noenter()"></td>
<td valign="top" >
<SELECT SIZE="1" NAME="SocialSciences">
<OPTION VALUE="ANTH" selected>ANTH</OPTION>
<OPTION VALUE="CANS">CANS</OPTION>

</SELECT>
<INPUT TYPE="text" NAME="SocSciCourseNo" VALUE="" SIZE=3 maxlength=3 onKeypress="if ((event.keyCode > 31 && event.keyCode < 48) || (event.keyCode > 57 && event.keyCode < 127)) event.returnValue = false; else return noenter()"> </td>
<td valign="top" >
<SELECT SIZE="1" NAME="Languages">
<OPTION VALUE="CLAS" selected>CLAS</OPTION>
<OPTION VALUE="EAST">EAST</OPTION>
<OPTION VALUE="ESLN">ESLN</OPTION>

</SELECT>
<INPUT TYPE="text" NAME="LangCourseNo" VALUE="" SIZE=3 maxlength=3 onKeypress="if ((event.keyCode > 31 && event.keyCode < 48) || (event.keyCode > 57 && event.keyCode < 127)) event.returnValue = false; else return noenter()">
</td>
<td valign="top" >
<SELECT SIZE="1" NAME="Maths-Sci">
<OPTION VALUE="ATOC" selected>ATOC</OPTION>
<OPTION VALUE="BIOL">BIOL</OPTION>
<OPTION VALUE="CHEM">CHEM</OPTION>

</SELECT>
<INPUT TYPE="text" NAME="HumCourseNo" VALUE="" SIZE=3 maxlength=3 onKeypress="if ((event.keyCode > 31 && event.keyCode < 48) || (event.keyCode > 57 && event.keyCode < 127)) event.returnValue = false; else return noenter()"> </td>
</tr>
<tr>
<td valign="top" >
<SELECT SIZE="1" NAME="humanities">
<OPTION VALUE="ARTH" selected>ARTH</OPTION>
<OPTION VALUE="CANS">CANS</OPTION>
<OPTION VALUE="CATH">CATH</OPTION>
<OPTION VALUE="CLAS">CLAS</OPTION>

</SELECT>
<INPUT TYPE="text" NAME="HumCourseNo" VALUE="" SIZE=3 maxlength=3 onKeypress="if ((event.keyCode > 31 && event.keyCode < 48) || (event.keyCode > 57 && event.keyCode < 127)) event.returnValue = false; else return noenter()"></td>
<td valign="top" >
<SELECT SIZE="1" NAME="SocialSciences">
<OPTION VALUE="ANTH" selected>ANTH</OPTION>
<OPTION VALUE="CANS">CANS</OPTION>
<OPTION VALUE="ECON">ECON</OPTION>

</SELECT>
<INPUT TYPE="text" NAME="SocSciCourseNo" VALUE="" SIZE=3 maxlength=3 onKeypress="if ((event.keyCode > 31 && event.keyCode < 48) || (event.keyCode > 57 && event.keyCode < 127)) event.returnValue = false; else return noenter()"> </td>
<td valign="top" >
<SELECT SIZE="1" NAME="Languages">
<OPTION VALUE="CLAS" selected>CLAS</OPTION>
<OPTION VALUE="EAST">EAST</OPTION>
<OPTION VALUE="ESLN">ESLN</OPTION>

</SELECT>
<INPUT TYPE="text" NAME="LangCourseNo" VALUE="" SIZE=3 maxlength=3 onKeypress="if ((event.keyCode > 31 && event.keyCode < 48) || (event.keyCode > 57 && event.keyCode < 127)) event.returnValue = false; else return noenter()">
</td>
<td valign="top" >
<SELECT SIZE="1" NAME="Maths-Sci">
<OPTION VALUE="ATOC" selected>ATOC</OPTION>
<OPTION VALUE="BIOL">BIOL</OPTION>
<OPTION VALUE="CHEM">CHEM</OPTION>

</SELECT>
<INPUT TYPE="text" NAME="HumCourseNo" VALUE="" SIZE=3 maxlength=3 onKeypress="if ((event.keyCode > 31 && event.keyCode < 48) || (event.keyCode > 57 && event.keyCode < 127)) event.returnValue = false; else return noenter()"> </td></tr>
<tr>
<td valign="top" >
<SELECT SIZE="1" NAME="humanities">
<OPTION VALUE="ARTH" selected>ARTH</OPTION>
<OPTION VALUE="CANS">CANS</OPTION>
<OPTION VALUE="CATH">CATH</OPTION>

</SELECT>
<INPUT TYPE="text" NAME="HumCourseNo" VALUE="" SIZE=3 maxlength=3 onKeypress="if ((event.keyCode > 31 && event.keyCode < 48) || (event.keyCode > 57 && event.keyCode < 127)) event.returnValue = false; else return noenter()"></td>
<td valign="top" >
<SELECT SIZE="1" NAME="SocialSciences">
<OPTION VALUE="ANTH" selected>ANTH</OPTION>
<OPTION VALUE="CANS">CANS</OPTION>
<OPTION VALUE="CATH">CATH</OPTION>

</SELECT>
<INPUT TYPE="text" NAME="SocSciCourseNo" VALUE="" SIZE=3 maxlength=3 onKeypress="if ((event.keyCode > 31 && event.keyCode < 48) || (event.keyCode > 57 && event.keyCode < 127)) event.returnValue = false; else return noenter()" > </td>
<td valign="top" >
<SELECT SIZE="1" NAME="Languages">
<OPTION VALUE="CLAS" selected>CLAS</OPTION>
<OPTION VALUE="CANS">CANS</OPTION>
<OPTION VALUE="CATH">CATH</OPTION>

</SELECT>
<INPUT TYPE="text" NAME="LangCourseNo" VALUE="" SIZE=3 maxlength=3 onKeypress="if ((event.keyCode > 31 && event.keyCode < 48) || (event.keyCode > 57 && event.keyCode < 127)) event.returnValue = false; else return noenter()">
</td>
<td valign="top" >
<SELECT SIZE="1" NAME="Maths-Sci">
<OPTION VALUE="ATOC" selected>ATOC</OPTION>
<OPTION VALUE="CANS">CANS</OPTION>

</SELECT>
<INPUT TYPE="text" NAME="HumCourseNo" VALUE="" SIZE=3 maxlength=3 onKeypress="if ((event.keyCode > 31 && event.keyCode < 48) || (event.keyCode > 57 && event.keyCode < 127)) event.returnValue = false; else return noenter()"> </td>
</tr>

</table>





<H4>&nbsp;</H4>
<center>
<BLOCKQUOTE><P><INPUT TYPE="submit" NAME="Submit Form"

VALUE="Submit"><INPUT TYPE="reset" VALUE="Reset"></P>


</BLOCKQUOTE>

</center>
<P>&nbsp;</P>

</FORM>

</BODY>

</HTML>
---
 
What do you have so far for the Javascript? Or did you want someone here to write the whole thing for you?

Lee
 
Actually i have other fields and validation rules written in javascript too but those are unrelated to this part. This is only a small part of a huge form. So my intention was not to get someone to write programs for me but to get some ideas so that i can at least initialize something to build up. I guess i am clear now. Do you want the whole javascript codings ? I guess thats gonna make it harder to understand.

Thanks

Gulluman
 
Doing this should be fairly simple. Here's what I would do:

1. Loop around all select elements, checking to see if their selectedIndex property is > -1

2. If it is, store a reference to that select element so that you can somehow text the associated text box (presumably the element names you've shown above are contrived - I can only assume that that is why there is so much duplication of names, and they have no relevance in some cases to the select element next to them)

3. If you have found 4 filled boxes, or reached the end of the loop, go to step 5.

4. Iterate round the loop started in step 1.

5. Now check all boxes associated with the 4 select elements you've kept track of.

On another note, your keypress filtering will only work in IE. You should consider removing it from online, and use scripting to attach the function to each element, for several reasons:

- Quicker page loading & reducded bandwidth

- Script can easily be made cross-browser by editing one function

Hope this helps,
Dan

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top