Open popup with text from textbox in url string

Discussion in 'JavaScript' started by richiej, Oct 26, 2006.

  1. #1
    Hi,

    I am trying to write a piece of javascript that will open a popup and include the the text from a textbox in the url. See below what I have so far. The javascript fires ok but instead of picking up the text from the box it keeps opening the url:
    ....AddClaimPerson.aspx?name=undefined

    Does anyone know where I am going wrong?

    thanks advance

    rich

    code:

    function DoPersonRedirect(control)
    {
    var search = control.value;
    var person = window.open('AddClaimPerson.aspx?name=' + search);
    }
     
    richiej, Oct 26, 2006 IP
  2. weirdwes

    weirdwes Peon

    Messages:
    6
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    How are you passing in the control parameter / calling this function?
     
    weirdwes, Oct 29, 2006 IP
  3. BurgerKing

    BurgerKing Active Member

    Messages:
    397
    Likes Received:
    23
    Best Answers:
    0
    Trophy Points:
    58
    #3
    What weirdwes was getting at is right - your function works, but you probably aren't calling it correctly.

    <script>
    function DoPersonRedirect(control)
    {
    var search = control.value;
    var person = window.open('AddClaimPerson.aspx?name=' + search);
    }
    </script>
    
    <input type="text" id="MyText">
    <input type="button" value="Click to Test" onClick="javascript:DoPersonRedirect(document.getElementById('MyText'))">
    Code (markup):
    This shows how to pass the control into your function.

    Cheers.
     
    BurgerKing, Oct 29, 2006 IP