• I’d like to include on one of my pages, a text input field, that when submitted, tells the browser to go to a predefined url + the value from the input text:

    i.e

    user enters into input field:

    myname

    on submit, browser goes to:

    https://www.pre-defined-website.com/myname

    Any ideas how I can do this? It’s a rudimentary login that someone wants to me sort out.

Viewing 5 replies - 1 through 5 (of 5 total)
  • How about a little javascript?

    jQuery(document).ready(function($){
     $('#BUTTONID').click(function(){
      document.localtion.href='https://www.mydomain.com/'+$('#FIELDID').val();
     });
    });

    Thread Starter alexondrums

    (@alexondrums)

    Excellent, thank you – I’m rusty on this sort of thing so will have to read up on how I implement it – in the meantime if anyone can explain, I’ll check back soon! Thanks

    Thread Starter alexondrums

    (@alexondrums)

    I’ve done a little testing and looking around. I’ve put the above jquery in a file, and point my form action at the .js file.

    When i submit, the broswer just displays the JQuery code on a page. Not sure if this is because I’ve not set up the form / JQuery correcly, or if it’s to do with my XAMPP setup. (doing all this on localhost)

    In the JQuery, I’ve changed #buttonid to the forms submit button ID value, and #fieldid to the forms input field ID. Guessing this is right? I’ve not used Javascript for years, and I’m very rusty on forms and server side stuff…

    Thread Starter alexondrums

    (@alexondrums)

    Could anyone familiar with this kind of thing lend a hand please? It would be great to get this working. Thanks!

    Thread Starter alexondrums

    (@alexondrums)

    Got it sorted ended with this:

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js" type="text/javascript"></script>
    
    <script>
    jQuery(document).ready(function($){
     $('#loginform').submit(function(){
      window.location = 'https://www.mydomain.com/'+$('#login').val();
      return false;
     });
    });
    </script>
    
    <form id="loginform">
    <input id="login" type="text">
    <input id="logingo" type="submit" value="Submit" />
    </form>
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Form input field >> URL value’ is closed to new replies.