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 5 of 5
  1. #1
    Regular Coder
    Join Date
    Mar 2005
    Location
    United States
    Posts
    271
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy Dont really know the subject, has to do with popups

    Hey I wanted to make something where when a person clicks a link a popup comes in the center of the page with a whole list of usernames. When the person clicks a username the popup closes and the username appears in a textbox. How can I do this?

  • #2
    Regular Coder
    Join Date
    Oct 2003
    Location
    on a ship
    Posts
    574
    Thanks
    1
    Thanked 6 Times in 5 Posts

    i got what you need!

    the pop up is a child window of the original window...
    you need a script in the child source code that does this:

    <body>
    <a href=#stayhere id='username1' onclick='LinkV(this.id);'>username1</a>
    </body>

    <script language=javascript>
    function LinkV(val){
    opener.document.getElementById('textarea').value=val;
    window.close();
    }
    </script>



    make sure you lable the link's id with what you want to pass back to main window.
    Last edited by brandonH; 04-14-2005 at 09:42 PM.

  • #3
    Regular Coder
    Join Date
    Mar 2005
    Location
    United States
    Posts
    271
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I really dont know anything about js, can you explain to me how to use it? I got it to where if you click a link it opens a popup with that code in it, but then what?

  • #4
    Regular Coder
    Join Date
    Oct 2003
    Location
    on a ship
    Posts
    574
    Thanks
    1
    Thanked 6 Times in 5 Posts

    correction to script

    in the <a> tag you need to make sure that the part I told you "this.value" says this.id (no quotes).
    <!-- this goes into child source code-->
    <body>
    <a href=#stayhere id='username1' onclick='LinkV(this.id);'>username1</a>
    </body>

    <script language=javascript>
    function LinkV(val){
    opener.document.getElementById('your text area id').value=val;
    window.close();
    }
    </script>
    <!--stop child source code>

    in the above where it says: opener.document.getElementById('your text area id').value=val;

    be sure the part that says 'your text area id' is the id value of the textarea or input you are using in the original document.


    <!--original window source-->

    <textarea id=textarea1></textarea>

    <!--end original window source-->



    how this works is if a window is opened by another window it is concidered to be a child window and the browser knows what window opened it. if you use opener.document.getElementById('textarea1').value='whatever' the browser know that the opener is the original window and then it goes from there with looking into the document and finding the element with the id textarea1 and then fills in the value.



    hope that helps clarify it.

    if not let me know

  • #5
    Regular Coder
    Join Date
    Mar 2005
    Location
    United States
    Posts
    271
    Thanks
    0
    Thanked 0 Times in 0 Posts
    THANKS A LOT! I got it to work.


  •  

    Posting Permissions

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