Change url in browser with textbox and submit button

Discussion in 'JavaScript' started by meddler, Nov 4, 2008.

  1. #1
    I'm currently after some simple javascript.

    I have a text box and submit button..! i want the user to type in say monkey and CLICK submit or the ENTER key. From here the form changes the url to http://www.mydomain.com/monkey

    Can someone please help me? I need to make sure that it works from the enter key not just by clicking.

    Thankyou in advance
     
    meddler, Nov 4, 2008 IP
  2. Bind

    Bind Peon

    Messages:
    70
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
  3. meddler

    meddler Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks for the link but this has confused me...!

    I'm a absolute beginner at javascript and dont know where to start apart from i have a text input ans submit button but thats as far as it goes.
     
    meddler, Nov 5, 2008 IP
  4. Bind

    Bind Peon

    Messages:
    70
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #4
    use javascript window.open() with the _self frame target, then use 'return false' to stop the form query_string submittal.

    
    <form name="thisform" action="" method="get" onsubmit="window.open('http://www.mydomain.com/'+document.thisform.url.value,'_self');return false;">
        <input name="url" type="text" />
        <input name="submit" type="submit" value="Go!" />
    </form>
    
    Code (markup):
     
    Bind, Nov 5, 2008 IP