Click to See Complete Forum and Search --> : radio buttons


Help
05-15-2003, 12:51 PM
What do u use knowing that the yes button is the first button in the group?

gil davis
05-15-2003, 01:03 PM
Since you have not posted the HTML for your radio button, I can only give you generalized syntax:document.formName.radioGroupName[0].checkedReplace "formName" with the name of the form, and "radioGroupName" with the name of the radio button. This will give "true" if the radio is checked, and "false" if it is not checked.

Charles
05-15-2003, 01:09 PM
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Content-Script-Type" content="text/javascript">
<form action="">
<div>
<label><input type="radio" name="group">Yes</label><br>
<label><input type="radio" name="group">No</label><br>
<label><input type="radio" name="group">Maybe so</label><br>
<button type="submit">Submit</button>
</div>
</form>

<script type="text/javascript">
<!--
document.forms[document.forms.length-1].onsubmit = function () {
if (this.group[0].checked) alert ('Yes');
if (this.group[1].checked) alert ('No');
if (this.group[2].checked) alert ('Maybe so');
}
// -->
</script>