Toon posts:

Retrieve Javascript variable from Inline Frame

Pagina: 1
Acties:
  • 38 views sinds 30-01-2008

Verwijderd

Topicstarter
Okay, I have a big javascript problem... I have an Inline Frame with option buttons, and I coded them so that whenever the selection is changed, a variable named i saves my value of that option button. Now I need to access this variable from the outside page, but don't know how to link to it.

So how do I access my variable in my Inline Frame, from the outside page, so I can use it in my script. Thx in advance. I added the code for the 2 pages (the main page and the inline frame) below.


-----------------------------------------------
MAIN PAGE


<html>
<body>

<script language="JavaScript">
<!--

function showMsg()
{
alert(window.testFrame.document.i);
}

// -->
</script>

<iframe name="testFrame" id="iFrame" src="testIframe.php">
Your browser does not support inline frames or is currently configured not to display inline frames.
</iframe>

<form name="testForm" onSubmit="return false">
<input name="checkButton" type="button" value="Show Variable" onclick="showMsg()">
</form>

</body>
</html>


--------------------------------------
INLINE FRAME


<html>
<body>

<script language="JavaScript">
<!--

function whatVar()
{
for (var i = 0; i < document.numberForm.number.length; i++)
{
if (document.numberForm.number[i].checked)
{
i = i + 1;
break
}
}
}

// -->
</script>

Choose your option:

<form name="numberForm" onSubmit="return false">
<input selected name="number" type="radio" value="1" onclick="whatVar();">1<br>
<input name="number" type="radio" value="2" onclick="whatVar();">2<br>
<input name="number" type="radio" value="3" onclick="whatVar();">3<br>
</form>

</body>
</html>

Verwijderd

Hi there, we would very much appreciate it if you posted your topic in Dutch, for this is a Dutch forum :)

Dit topic is gesloten.