Form value creates url

I am trying to create a very simple form with a little extra code to get the results as described below: the problem is that I do not know how to do this.

What I'm trying to achieve:

I have a form that has one text input field called "url". I want the user to be able to enter a number in the field. When the user submits the form, they must be redirected to the new website. The new website URL will be based on the amount entered on the form.

The first part of the URL will always be: http://name.com/

Then the number that the user enters will be attached to the end. Therefore, if 123456 is entered into the form, then when the form is submitted, the user will be transferred to http://name.com/123456

Does anyone have any ideas on how I can make this work? Having guessed that this would require JavaScript or something else?

+4
source share
3 answers
<script> function process() { var url="http://name.com/" + document.getElementById("url").value; location.href=url; return false; } </script> <form onSubmit="return process();"> URL: <input type="text" name="url" id="url"> <input type="submit" value="go"> </form> 
+11
source

You can add onsubmit="this.action='http://google.com/'+this.fieldName.value;" into your tag.

+6
source

This should do it:

 <script type="text/javascript"> function goToPage() { var page = document.getElementById('page').value; window.location = "http://name.com/" + page; } </script> <input type="text" id="page" /> <input type="submit" value="submit" onclick="goToPage();" /> 
+1
source

All Articles