Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help with passing text from window to window

Status
Not open for further replies.

GregArtemides

Programmer
May 23, 2003
12
CY
I have a page, Page1.htm containing a form with a textfield, and a link which pops up another page, Page2.htm. Page2.htm contains an iframe.

When I press the link on Page1 to popup Page2, I would like to pass the text in the textfield on Page1 to the iframe on Page2.

Finally I would like to do the reverse. Pass the text from the iframe in page2 to the textfield on page1, by clicking a link on page2.

How do I do that?
 
Try using asp pages to pass variables from one page to another

Lee

Alone we can do so little, together we can do so much
 
You could create a frame set with two windows. One window would be be hidden i.e 0% width and the other 100%. In the hidden window create a custom object i.e

var objSelected = new Object();

In the main window onsubmit store the form element values in the new object. i.e

var objSelection = parent.frames[0].window.objSelected;
objSelection.State = window.document.myForm.myTextBox.value;

Set the form tag's target to _self and the action to next page.

In the next page retrieve the values and set the form element values by calling a function from the onLoad event .i.e

function Load()
{
var objSelection = parent.frames[0].window.objSelected;
window.document.myForm.mytextBox2.value = objSelection.State;
}

<body onLoad='Load90' >

Cheers


 
JohnBear, your solution would work. I have actually found a different approach that works too. Here it is:
Page1:
<!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;>
<html>
<head>
<title>Untitled</title>
<script language=&quot;JavaScript&quot; type=&quot;text/javascript&quot;>
<!--
var textfieldId;
function openWin(){
toBeTransferred=document.forms[0].textP1.value;
newWin=window.open('Page2.htm','','width=450,height=300');
}
//-->
</script>
</head>
<body>
<form>
<table width=&quot;0%&quot; border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;>
<tr>
<td><input type=&quot;text&quot; name=&quot;textP1&quot; onBlur=&quot;javascript: textfieldId=this;&quot;> </td>
<td rowspan=&quot;3&quot;> <a href=&quot;javascript:eek:penWin()&quot;>open Popup</a></td>
</tr>
<tr>
<td><input type=&quot;text&quot; name=&quot;textP2&quot; onBlur=&quot;javascript: textfieldId=this;&quot;> </td>
</tr>
<tr>
<td><input type=&quot;text&quot; name=&quot;textP3&quot; onBlur=&quot;javascript: textfieldId=this;&quot;> </td>
</tr>
</table>
</body>
</html>

Page2:
<!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;>
<html>
<head>
<title>Untitled</title>
</head>
<body>
<iframe src=&quot;Page3.htm&quot; name=&quot;i1&quot;></iframe>
<br>
<br>
</body>
</html>

Page3
<!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;>
<html>
<head>
<title>Untitled</title>
<script language=&quot;JavaScript&quot; type=&quot;text/javascript&quot;>
<!--
function getIt(){
document.forms[0].itext1.value=parent.window.opener.textfieldId.value;
}
function transfer(){
parent.window.opener.textfieldId.value=document.forms[0].itext2.value;
}
//-->
</script>
</head>
<body onload=&quot;getIt()&quot;>
<form>
Text from parent: <input type=&quot;text&quot; name=&quot;itext1&quot;><br>
Text to parent: <input type=&quot;text&quot; name=&quot;itext2&quot;><br>
<input type=&quot;button&quot; value=&quot;transfer&quot; onclick=&quot;transfer()&quot;>
</form>
</body>
</html>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top