I have two drop down boxes that need to be validated separately. When the one function is called, for some strange reason I am prompted with my alert box and focus is set to the other drop down box, preventing me from updating the value chosen.
Here are the functions and code:
[CODE] <script language=”JavaScript”>
function Validate(form2)
{
if(document.form2.PegNumberDrawn.selectedIndex==0)
{
alert(“Please choose the Peg Number Drawn for this angler.”);
document.form2.PegNumberDrawn.focus();
return false;
}
return true;
else
}
</script>
<script language=”JavaScript”>
function Validate(form3)
{
if(document.form3.PegNumberDrawn_Day2.value==0)
{
alert(“Please choose the Peg Number Drawn for this angler.”);
document.form3.PegNumberDrawn_Day2.focus();
return false;
}
else
{
document.form3.submit();
}
}
</script>
Drop Down box:
[CODE]
<table>
<tr>
<td>
<form method=”post” action=”thepage.asp” name=”form2″>
<input type=”hidden” value=”<%=RSCustomers(“CustomerId”)%>” name=”CustomerId”>
<input type=”hidden” value=”<%=FishId%>” name=”FishId”>
<input type=”hidden” value=”Second” name=”DatabaseNumber”>
<select NAME=”PegNumberDrawn” SIZE=”1″>
<option VALUE=””><%=PegNumberDrawn%>
<option VALUE=”1″>1
<option VALUE=”2″>2
<option VALUE=”3″>3
<option VALUE=”4″>4
<option VALUE=”5″>5
</select>
<input type=”BUTTON” onclick=”Validate(form2);return false;” value=”Update Peg” name=”submit1″ align=”left”>
</form>
</td>
</tr>
</table>
</form>
<table>
<tr>
<td>
<font color=”white” size=”4″><u><b>Peg Number Drawn – Day 2<b></u></font>
<br>
<form method=”post” action=”AssignPegNumberDrawnUpdate_Second.asp” name=”form3″>
<input type=”hidden” value=”Yes” name=”SecondDay_PegDraw”>
<input type=”hidden” value=”<%=RSCustomers(“CustomerId”)%>” name=”CustomerId”>
<input type=”hidden” value=”<%=FishId%>” name=”FishId_PegNumberDrawn_Day2_FishId”>
<input type=”hidden” value=”Second” name=”DatabaseNumber”>
<select NAME=”PegNumberDrawn_Day2″ SIZE=”1″>
<option VALUE=””><%=RS_PegNumberDrawn_Day2(“PegNumberDrawn_Day2″)%>
<option VALUE=”1″>1
<option VALUE=”2″>2
<option VALUE=”3″>3
<option VALUE=”4″>4
<option VALUE=”5″>5
</select>
<input type=”BUTTON” onclick=”Validate(form3);return false;” value=”Update Peg – Day 2″ name=”submit1″ align=”left”>
</form>
</td>
</tr>
</table>