-----Original Message-----
I have a table containing among other things 15 radio
buttons, each in its own cell. I want users of the form
containing the table to be able to vote for no more than
3 out the 15 available options. How do I arrange things
such that if a user checks 4 or more radio buttons a
message appearsadvising them to select no more than 3
options, and doesn't allow them to proceed/submit?
Well, first you should probably use checkboxes rather
than radio buttons. You can only select ohe radio button
in the same group. (Or do you have 15 *sets* of radio
buttons?)
Next, change your form's Submit button to an ordinary
pushbutton, and point its onclick attribute to a
JavaScript function. Here's an example:
<input type="button" value="Submit" name="B1"
onclick="subForm();">
Then, write a subForm function like this:
<script>
function subForm(){
var ckcnt = 0;
if (document.forms[0].C1.checked){ckcnt = ckcnt + 1;}
if (document.forms[0].C2.checked){ckcnt = ckcnt + 1;}
// checkboxes 3-14 follow same pattern...
if (document.forms[0].C15.checked){ckcnt = ckcnt +1 ;}
if (ckcnt > 3){
alert("Select at most 3 items.")
}else{
document.forms[0].submit();
}
}
</script>
Jim Buyens
Microsoft FrontPage MVP
(e-mail address removed)
http://www.interlacken.com
Author of:
*------------------------------------------------------*
|\----------------------------------------------------/|
|| Microsoft Office FrontPage 2003 Inside Out ||
|| Microsoft FrontPage Version 2002 Inside Out ||
|| Web Database Development Step by Step .NET Edition ||
|| Troubleshooting Microsoft FrontPage 2002 ||
|| Faster Smarter Beginning Programming ||
|| (All from Microsoft Press) ||
|/----------------------------------------------------\|
*------------------------------------------------------*