Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Apr 2008
    Posts
    11
    Thanks
    2
    Thanked 0 Times in 0 Posts

    How to pass data from parent window to popup window ?

    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....

  • #2
    Regular Coder Stooshie's Avatar
    Join Date
    Mar 2008
    Location
    Dundee, Scotland
    Posts
    378
    Thanks
    9
    Thanked 39 Times in 39 Posts
    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:
    Code:
    <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:
    Code:
    <input type="text" id="parentTextBox"/>
    <input type="button" onclick="transferText();"/>
    hope it helps.
    Regards, Stooshie
    O

  • #3
    New Coder
    Join Date
    Apr 2008
    Posts
    11
    Thanks
    2
    Thanked 0 Times in 0 Posts
    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.........

  • #4
    New Coder
    Join Date
    Apr 2008
    Posts
    11
    Thanks
    2
    Thanked 0 Times in 0 Posts
    I have done it using Query String.......


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •