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 to the CF scene
    Join Date
    Jun 2003
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    sending Child values back to parent

    before putting this simple question I looked into existing questions, but unfortunately I couldn't find the most related.

    I have jsp A having txt box and search button associated to it after click it opens child window with list of peoples and id (UID-First and Last name)

    What I need is, once you select any uid, child window should be closed and value of UID (only) should be passed back to parent window (I have txtbox in parent window for it)

    thanks in advance

  • #2
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    Experiment with the following



    In the opener

    <P><form name="f1">
    <P><input type="text" name="t1" value="Receiving Textbox" size="30" <a href="#null" onclick="popit=open('opened1.htm','pop','top=280,left=390,width=300,height=200');popit.focus()">Open Popup</a>
    <P><div id="oDIV">Text From Popup</div>
    </form>


    --------------------------------------------------------------------------------

    In the Popup

    <script language="javascript">
    <!--
    function transfer(str){
    if (opener && !opener.closed){
    opener.document.f1.t1.value=str;
    }
    }
    </script>

    <form name="f1">
    <a href="javascript:transfer('This is from the popup link 1')"> Link 1</a>
    <P> <button onclick="opener.oDIV.innerHTML='<font color=red> Sample Text From Popup</font>'">Enter Div Text</button>
    <P> <input type="text" name="t1" value="Type Some Text In Here"> <input type="button" value="Send" onclick="transfer(document.f1.t1.value)"> <BR>
    <P> <button onclick="window.close()"> Done</button>
    </form>




  • #3
    Senior Coder
    Join Date
    Aug 2002
    Posts
    3,467
    Thanks
    0
    Thanked 0 Times in 0 Posts
    To access a popup window's opener document, just use

    window.opener

    And from there, you can access he full DOM for the parent window. So, if you have a form "myForm" with an element "myElement"

    window.opener.document.myForm.myElement.value = someValue;
    My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
    “Minds are like parachutes. They don't work unless they are open”
    “Maturity is simply knowing when to not be immature”

  • #4
    New to the CF scene
    Join Date
    Jun 2003
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post I have added my code

    Thank you for quick response

    here is my code.

    main page

    <FORM name="MainPage" method="POST" onsubmit= "return validateData()" action="/Servlets/results">
    <TABLE>
    <TR>
    <TD>Username &nbsp;</TD><TD><input type="text" name="txtUserid" size="20" tabindex="1"></TD>
    <TD> <A href="javascript:getIDs('http://Servlets/editorslist.jsp')"><IMG src="/Servlets/searchable.gif" border="0" ALT="Get Editor User Id"> </A></TD>
    </TR>
    function getIDs(PopUpUrl)
    {
    var ScreenWidth=window.screen.width;
    var ScreenHeight=window.screen.height;
    var movefromedge=0;
    placementx=(ScreenWidth/2)-((400)/2);
    placementy=(ScreenHeight/2)-((300+50)/2);
    WinPop=window.open(PopUpUrl,"","width=400,height=300,toolbar=0,location=0,directories=0,status=0,scr ollbars=0,menubar=0,resizable=0,left="+placementx+",top="+placementy+",screenX="+placementx+",screen Y="+placementy+",");
    }

    in search window (.jsp)
    <html>
    <body>
    <form name="editorlist" onclick="javascript:transfer(editorlist.editorid.value)" >
    <select name="editorid" size=15 >
    <%= getOptions()%>
    </select>
    </form>
    </body>
    </html>
    function transfer(str)
    {
    opener,document.MainPage.txtUserid.value=str;
    window.close();

    }


    thanks in advance.


  •  

    Posting Permissions

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