Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q1120 How I get get the value of a selected radio button from another frame?

You are here: irt.org | FAQ | JavaScript | Form | 10.3 | Q1120 [ previous next ]

If it is to be compatible with Internet Explorer 3, you will need to access the radios as simple elements:

<form name="myForm">
<input type="text">
<input type="text">
<input type="radio" name="rad" value="1">1
<input type="radio" name="rad" value="2">2
<input type="radio" name="rad" value="3">3
<input type="radio" name="rad" value="4">4
</form>

In the other frame use:

<script language="JavaScript"><!--
theRadioValue = 0;
/* we need to start at the third element - element number 2 - javascript counts from 0 */

for (i=2, n=parent.otherframe.document.myForm.elements.length; i<n; i++) {
    if (parent.otherframe.document.myForm.elements[i].checked) {
        theRadioValue = parent.otherframe.document.myForm.elements[i].value;
        break;
    }
}
//--></script>

©2018 Martin Webb