View Full Version : Passing a variable from a 2 frame popup to main page

01-03-2007, 07:02 AM
I have a main page lets say called main.php. In there I have a text box called manager. Next to it, I have a link where when clicked it opens a popup box.

This popup box has two frames, top and bottom. The top one prompts the user to search for manager name. The bottom section lists down all managers. After selecting the required manager in the bottom section using radio button, there is an update button where when clicked, the record should be updated in the textbox in main.php.

I got all to work except for the part where I cannot update the selected record back to the main page. Can someone help me?

01-03-2007, 05:37 PM
Then, i think you have this situation: a main page and a popup with 2 frames, right?

Let's suppose that the structure of your popup is something like this:

<frameset rows="50%, 50%" border="0">
<frame src="page1.html">
<frame src="page2.html">

And let's suppose too that the structure of your main page is something like this:

<textarea id="mainText" name="mainText" rows="6" cols="60"></textarea>

If you want to pass text content from the "page2.html" in the popup to the main page, you can do it as the follow:

//code in page2.html

parent.frames.opener.document.getElementById("mainText").value = "SOME TEXT";


I've simulated here and it worked.

I hope this can help you. And if you need some help, post again! :thumbsup:

01-04-2007, 07:17 AM
Thanks !