I have a php script that has a form for entering requests for materials for the classroom. The user has a choice of entering a single grade, or multiple grades. If the user requests materials for multiple grades, she is asked how many grades, from there, the input fields are set like this:
How Many Grades: 3
<table border="0" cellpadding="3" cellspacing="0">
<tr>
<th>How Many Grades? </th>
<td><input type="text" name="req_grades" size="5" maxlength="8" value="3" onChange="submit()" /></td>
</tr>
<tr>
<th>Grade 1: </th>
<td>
<select name="req_grade_1">
<option value="">Select</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
</select>
</td>
<th>Number: </th>
<td><input type="text" name="req_grade_num_1" value="" size="5" maxlength="10" /></td>
</tr>
<tr>
<th>Grade 2: </th>
<td>
<select name="req_grade_2">
<option value="">Select</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
</select>
</td>
<th>Number: </th>
<td><input type="text" name="req_grade_num_2" value="" size="5" maxlength="10" /></td>
</tr>
<tr>
<th>Grade 3: </th>
<td>
<select name="req_grade_3">
<option value="">Select</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
</select>
</td>
<th>Number: </th>
<td><input type="text" name="req_grade_num_3" value="" size="5" maxlength="10" /></td>
</tr>
</table>
Where x in the req_grade_num_x and req_grade_x is set by php in a for loop.
What I need to know is how, in JavaScript to set focus on any of these fields left blank or unselected since this number will vary from 2-3 (actually 2-13 in real life)
How Many Grades: 3
<table border="0" cellpadding="3" cellspacing="0">
<tr>
<th>How Many Grades? </th>
<td><input type="text" name="req_grades" size="5" maxlength="8" value="3" onChange="submit()" /></td>
</tr>
<tr>
<th>Grade 1: </th>
<td>
<select name="req_grade_1">
<option value="">Select</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
</select>
</td>
<th>Number: </th>
<td><input type="text" name="req_grade_num_1" value="" size="5" maxlength="10" /></td>
</tr>
<tr>
<th>Grade 2: </th>
<td>
<select name="req_grade_2">
<option value="">Select</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
</select>
</td>
<th>Number: </th>
<td><input type="text" name="req_grade_num_2" value="" size="5" maxlength="10" /></td>
</tr>
<tr>
<th>Grade 3: </th>
<td>
<select name="req_grade_3">
<option value="">Select</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
</select>
</td>
<th>Number: </th>
<td><input type="text" name="req_grade_num_3" value="" size="5" maxlength="10" /></td>
</tr>
</table>
Where x in the req_grade_num_x and req_grade_x is set by php in a for loop.
What I need to know is how, in JavaScript to set focus on any of these fields left blank or unselected since this number will vary from 2-3 (actually 2-13 in real life)