Prasad Bolla's SharePoint Blog

Click Here to go through the Interesting posts within my Blog.

Click Here to go through the new posts in my blog.

Monday, December 05, 2011

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>

No comments:

Post a Comment