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 8 of 8
  1. #1
    Regular Coder
    Join Date
    Aug 2003
    Location
    scotland, edinburgh
    Posts
    176
    Thanks
    5
    Thanked 1 Time in 1 Post

    put text into input box via a pop up

    Ok I have an input box that requires the user to put in a name of a file.

    So that the user is able to put in the name of that file easier I have made a link next to the input box saying "find file" when they click on it a new window pops up displaying all the files in a folder on my server.

    So far I have manged that.
    >>http://www.eugamers.com/hl2dq/hl2dqupdate.php

    But now I need some way of the user selecting a file name from that list in the new window and then that file name then gets inserted into the input box on the original page.
    Note that there are a list of file names needing to be entered so I want to make sure it goes into the input box that the user wants it to. That would most likley be the one that was clicked next to the "find file" link.

    Would anyone be able to give some help on this.

    As always thank you for your time.

  • #2
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    This should work in the popup:

    Code:
    <a href="javascript:opener.parentNode.getElementsByTagName('input')[0].value='this.innerHTML'">filelist.php</a>
    .....Willy

  • #3
    Regular Coder
    Join Date
    Aug 2003
    Location
    scotland, edinburgh
    Posts
    176
    Thanks
    5
    Thanked 1 Time in 1 Post
    ok i put that code into the filelist.php so that all the links have that in them but when i click on them it comes up with an error saying
    "opener.parentNode is null or not an object"
    Would you bea able to help on that
    Thanks

  • #4
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You will probably need to use a function on the parent page to capture and register which element was clicked on and then reference that function in the popup...

  • #5
    Regular Coder
    Join Date
    Aug 2003
    Location
    scotland, edinburgh
    Posts
    176
    Thanks
    5
    Thanked 1 Time in 1 Post
    yeah i have seen it done before with like smilies like in a shout box you click on a link and a popup comes up with a list of smilies and then u click on one and it goes into the input box.
    I have no idea how that is done, the only thing i know is onFocus is usally used for these kind of things but I have no idea how to use it in this situation

  • #6
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    No, what you are thinking about targets one particular form element on the opener page... What you are trying to do is target various form elements depending upon which anchor was clicked...

    I thought walking back up the DOM would work by referencing the anchors parentNode (TD) and back down children of the parentNode to the first input of the parentNode... But, obviously from another window it is not registering which anchor was clicked on...

    So you have two choices, write a function which will capture, register and store which anchor was clicked on so you can use it from the popup or explicitly define which form element to pass the value from the popup too...

    .....Willy

  • #7
    Regular Coder
    Join Date
    Aug 2003
    Location
    scotland, edinburgh
    Posts
    176
    Thanks
    5
    Thanked 1 Time in 1 Post
    I have decicded for the first choice where I need:
    a function which will capture, register and store which anchor was clicked on so you can use it from the popup
    But so far I have been unable to understand how to do such a thing
    so far I have this
    Main Page:
    Code:
    ""I cant seem to put in the html for the input boxes in, everytime i try and 
    submit with them in an error comes up in the forums saying 'You have 
    included too many images in your signature or in your previous post'
    basically the from name is stockForm and the input boxes are called stockBox, stockBox2, stockBox3. ""
    
    <SCRIPT LANGUAGE="JavaScript">
    			function openpopup(popurl){
      sList=window.open(popurl, "list", "width=150,height=210");
    }
    
    function remLink() {
      if (window.sList && window.sList.open && !window.sList.closed)
        window.sList.opener = null;
    }
    
    // -->
    </SCRIPT>
    Pop UP:
    Code:
    <HTML>
    <HEAD>
    <TITLE>Stock List</TITLE>
    <SCRIPT LANGUAGE="JavaScript">
    <!--
    
    function pick(symbol) {
      if (window.opener && !window.opener.closed)
        window.opener.document.stockForm.stockBox.value = symbol;
      window.close();
    }
    
    // -->
    </SCRIPT>
    </HEAD>
    <BODY>
    <TABLE BORDER="1" CELLSPACING="0" CELLPADDING="5">
    <TR BGCOLOR="#cccccc"><TD><B>main</B></TD><TD><B>other</B></TD></TR>
    <TR><TD><A HREF="javascript:pick('AOL.psp')">AOL.psp</A></TD>
    <TD><A HREF="javascript:pick('CSCO.txt')">CSCO.txt</A></TD></TR>
    <TR><TD><A HREF="javascript:pick('CPQ.txt')">CPQ.txt</A></TD>
    <TD><A HREF="javascript:pick('INTC.txt')">INT.txtC</A></TD></TR>
    <TR><TD><A HREF="javascript:pick('NOK.txt')">NOK.txt</A></TD>
    <TD><A HREF="javascript:pick('SUNW.txt')">SUNW.txt</A></TD></TR>
    <TR><TD><A HREF="javascript:pick('LU.txt')">LU.txt</A></TD>
    <TD><A HREF="javascript:pick('AMZN.txt')">AMZN.txt</A></TD></TR>
    <TR><TD><A HREF="javascript:pick('T.txt')">T.txt</A></TD>
    <TD><A HREF="javascript:pick('MSFT.txt')">MSFT.txt</A></TD></TR>
    </TABLE>
    </BODY>
    </HTML>
    From that I think its the Pick function which needs the variable from the main page as the stockBox needs to change according to what link was pressed

    So basically how can I transfer a variable from the link to the pop up window so that stockBox becomes stockBoxn

    Thanks
    Last edited by tsclan; 12-13-2004 at 04:18 AM.

  • #8
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts


  •  

    Posting Permissions

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