...

View Full Version : How to pass data from parent window to popup window ?



mithilesh
04-23-2008, 03:25 PM
Hiii All,

Can anybody tell me how data can be passed from parent window to popup window
I have used window.open function and opened 1 page . I am getting data from popup window to text field in parent window.
Now I want to display the data from textfield in popup window on a button click.
Is it possible????




Thanxxx in advance....

Stooshie
04-23-2008, 04:58 PM
If I understand you correctly, you have a parent window with a textfield and a popup with a textfield and you want to get text from the parent window textfield to the popup window textfield.

in the head:


<script type="text/javascript">
function init()
{
popupWin = window.open('','popupWin','');
popupWin.document.writeln('<html><head><title>test</title></head><body><form><input type="text" id="popupTextBox"/></form></body></html>');
popupWin.document.close();
popupText = popupWin.document.getElementById("popupTextBox");
parentText = document.getElementById("parentTextBox");
}
function transferText()
{
popupText.value = parentText.value
}
</script>

in the body:


<input type="text" id="parentTextBox"/>
<input type="button" onclick="transferText();"/>

hope it helps.

mithilesh
04-24-2008, 08:11 AM
Thanks Stooshie for giving the code.
I have one more question,I hope you will help me out in that too :)
I have used following code :
<HTML>
<HEAD>
<title>WebForm8</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
<script type="text/javascript">
function init()
{
popupWin = window.open('WebForm6.aspx','popupWin','width=610,height=400');
popupWin.document.close();
popupText = popupWin.document.getElementById("FreeTextBox1");
parentText = document.getElementById("parentTextBox");
popupText.value = parentText.value
}
</script>
</HEAD>
<body MS_POSITIONING="GridLayout" >
<form id="Form1" method="post" runat="server">
<input type="text" id="parentTextBox"> <input type="button" onclick="init();">
</form>
</body>
</HTML>


Now in above code I have given path of WebForm6.aspx in popup window i.e in window.open

I am using FreeTextBox control in WebForm6.aspx which have id as FreeTextBox1
Now when button is clicked , I am getting an error as:
Microsoft JScript runtime error: 'popupText' is null or not an object
How this can be solved?

Thnxx Once Again.........

mithilesh
04-25-2008, 06:20 AM
I have done it using Query String.......



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum