2

The story: I have three files, Base.html, miniChallenge.html and miniChlgame.html... I declared a global variable (hopefully I did so correctly) in Base.html with the following code:

Base.html

<head>
    <script type="text/javascript">
        var clgteam;
    </script>
</head>

To clarify something, if I am using an iframe to display another html[miniChallenge.html], am I right to say that Base.html is the parent of miniChallenge.html?

In miniChallenge.html, I have radio buttons that have different values and the user selects one of them before clicking a button that prompts a popup confirm box. At this point, I want to write the value of the radio button (in my case, James88, but I do not want this to be fixed as there are several options) into the global variable 'clgteam', declared in [Base.html]. I do this with the following code:

window.opener.document.clgteam.value = chkedRadio;  

where chkedRadio is the value of the selected radio button

After that, when the user clicks the OK button on the confirm box, the iframe will then load miniChlgame.html where there are two labels and one of them should display the value (James88) of 'clgteam', and I do so by using this code:

document.getElementById('awayteam').innerHTML =  window.opener.document.clgteam.value;

where 'awayteam' is the ID of the label.

However, it does not work and I've tried various methods. Please enlighten me!!

(I am complete new to HTML, CSS and JavaScript so please pardon my idiocy. I have searched online, seen various solutions, but I am still unable to adopt them to solve my problem.)

Community
  • 1
  • 1
DG85
  • 43
  • 4

1 Answers1

0
window.opener.document.clgteam.value = chkedRadio;

can't work since clgteam is not an HTML element.

Depending on browsers capabilities (HTML 5 or not) you can achieve this using iframe communication.

Francois
  • 10,730
  • 7
  • 47
  • 80