submit button help

Discussion in 'HTML & Website Design' started by mhrlive, Oct 25, 2011.

  1. #1
    Hello,
    I want the code to get a button and a text input with html , when click on submit button he will be redirected to a page with url include his entered text like this : www.website.com/"text input"

    its very simple , but Im beginner so help me :)
     
    Solved! View solution.
    mhrlive, Oct 25, 2011 IP
  2. #2
    Ok explain me in simple formate. you want one text input with submit button and when some one will enter some text he will redirect some link . e.g http://test.com/TEXT_FROM_BOX?

    Here is the code!!


    <script type="text/javascript">

    function red(){
    var base_url = "http://www.test.com/"; // add your url with trailing slash.
    var txt = document.getElementById("user_text").value;
    if(txt == "") { alert('Enter some text'); } else { window.location = base_url + txt; }
    }

    </script>
    <input type="text" size="30" name="user_text" id="user_text" />
    <input type="button" onclick="red()" value="Submit / Redirect" />
     
    manjifera, Oct 26, 2011 IP
  3. mhrlive

    mhrlive Active Member

    Messages:
    64
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    73
    #3
    Thank you manjifera , your code work fine, I appreciate your help .
     
    mhrlive, Oct 26, 2011 IP