View Full Version : passing variables to an iframe page

01-11-2007, 01:06 AM
Hi all,

THis may sounds classic to some experts out there but I cannot google out the right answer. Here we go again:

I have 1 main page(mainpage) and 2 iframes(ifram_left & iframe_right) within that main page. I have couple of checkbox and a drop downlist on the mainpage for navigation with a submit button (for ALL inputs selected) I dont know how to:
a) capture the values (collectively) from those inputs and pass them to either iframes.
b) pass variables from iframe_left to other inframe_right
c) on either iframe page, how to receive passing variables from mainpage and/or the other iframe page for processing.

Can some of you show me the way/links? Is cookie a better choice or??? Thanks in advance

01-14-2007, 02:27 AM
Not sure about iframes, but here s what you can do with frames:


hope it helps,


01-14-2007, 06:34 AM
I found how i can pass the variable from a main page (form) to an Iframe page (form1) but I have a dilema. ..How do I automatically capture the value of the textfield in (Iframe) page after it is populated by sending page.
How do I:
a) run the function Show() when the textfield in iframepage is populated by the parent page (mainpage)
b) how do parse/extract the passing value from the textfield (in iframepage).


Here is my code for passing the variable.


<form name="form" method="post" action="">

<input type="text" name="textfield" />
<input type="button" name="button" name="button"
<iframe name="myIframe" src="iframepage.htm"</p>


<script type="text/javascript">
var x=document.getElementById("form1").textfield.value
<form name="frame1" method="post">
<input type="text" name="textfield" onclick="show()"/>
<!-- onchange dont work here-->

01-14-2007, 07:59 PM
<script type="text/javascript">
var copying = false;

function copy(formName, fromName, frameName, frameFormName, toName) {
if(!copying) return;
var to = window.frames[frameName].document.forms[frameFormName].elements[toName],
from = document.forms[formName].elements[fromName];
to.value = from.value;
window.setTimeout(function() { copy(formNum, fromName, frameName, frameFormName, toName); }, 300);

function beginCopy(formName, fromName, frameName, frameFormName, toName) {
copying = true;
copy(formNum, fromName, frameName, frameFormName, toName);

function endCopy() {
copying = false;