IndyB
07-14-2003, 08:57 AM
I've got the following code that I though would work, but I must be missing something. The form has multiple radio buttons and multiple submit buttons. Regardless of which submit button is selected, I need to check and make sure that one of the radio buttons is selected.
Here's the HTML:
<tr>
<td colspan="3"><h5>Search for Claims Exceptions by:<br>
</h5></td>
</tr>
<tr>
<td width="24%" bgcolor="#ececec">Certificate #:</td>
<td width="9%" align="center" bgcolor="#ececec"><input type="radio" name="radio" value="cert"></td>
<td width="67%" rowspan="4" align="center" valign="bottom">
<table width="60%" border="0" cellspacing="0" cellpadding="4">
<tr>
<td colspan="2">View Results By:</td>
</tr>
<tr>
<td width="50%"><input type="button" value="Un-Reviewed" onClick="this.form.action='default.cfm?view_by=un_revd';this.form.submit();"></td>
</tr>
<tr>
<td><input type="button" value="Reviewed" onClick="this.form.action='default.cfm?view_by=revd';this.form.submit();"></td>
</tr>
<tr>
<td><input type="button" name="Submit" value="All" onclick="this.form.action='default.cfm?view_by=all';this.form.submit();"></td>
</tr>
</table>
</td>
</tr>
<tr>
<td bgcolor="#ececec">Policy:</td>
<td align="center" bgcolor="#ececec"> <input type="radio" name="radio" value="policy"></td>
</tr>
<tr>
<td bgcolor="#ececec">Sub-Group:</td>
<td align="center" bgcolor="#ececec"> <input type="radio" name="radio" value="subgroup"></td>
</tr>
<tr>
<td bgcolor="#ececec" nowrap>Century #:</td>
<td align="center" bgcolor="#ececec"> <input type="radio" name="radio" value="century"></td>
</tr>
</form>
Here's the JavaScript:
// JavaScript Document
function valbutton(thisform) {
myOption = -1;
for (i=0; i<thisform.radio.length; i++) {
if (thisform.radio[i].checked) {
myOption = i;
}
}
if (myOption == -1) {
alert("You must select a search option.");
return false;
}
// place any other field validations that you require here
thisform.submit(); // this line submits the form after validation
}
Here's the HTML:
<tr>
<td colspan="3"><h5>Search for Claims Exceptions by:<br>
</h5></td>
</tr>
<tr>
<td width="24%" bgcolor="#ececec">Certificate #:</td>
<td width="9%" align="center" bgcolor="#ececec"><input type="radio" name="radio" value="cert"></td>
<td width="67%" rowspan="4" align="center" valign="bottom">
<table width="60%" border="0" cellspacing="0" cellpadding="4">
<tr>
<td colspan="2">View Results By:</td>
</tr>
<tr>
<td width="50%"><input type="button" value="Un-Reviewed" onClick="this.form.action='default.cfm?view_by=un_revd';this.form.submit();"></td>
</tr>
<tr>
<td><input type="button" value="Reviewed" onClick="this.form.action='default.cfm?view_by=revd';this.form.submit();"></td>
</tr>
<tr>
<td><input type="button" name="Submit" value="All" onclick="this.form.action='default.cfm?view_by=all';this.form.submit();"></td>
</tr>
</table>
</td>
</tr>
<tr>
<td bgcolor="#ececec">Policy:</td>
<td align="center" bgcolor="#ececec"> <input type="radio" name="radio" value="policy"></td>
</tr>
<tr>
<td bgcolor="#ececec">Sub-Group:</td>
<td align="center" bgcolor="#ececec"> <input type="radio" name="radio" value="subgroup"></td>
</tr>
<tr>
<td bgcolor="#ececec" nowrap>Century #:</td>
<td align="center" bgcolor="#ececec"> <input type="radio" name="radio" value="century"></td>
</tr>
</form>
Here's the JavaScript:
// JavaScript Document
function valbutton(thisform) {
myOption = -1;
for (i=0; i<thisform.radio.length; i++) {
if (thisform.radio[i].checked) {
myOption = i;
}
}
if (myOption == -1) {
alert("You must select a search option.");
return false;
}
// place any other field validations that you require here
thisform.submit(); // this line submits the form after validation
}