Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

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

irt.org | Knowledge Base | JavaScript | Form 10.3 | Q1120 [ previous next ]

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

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>

Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 30th March 2008. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2008 irt.org, All Rights Reserved.