Form to open URL slash the viarable (e.g localhost/"user entry")

57 Views Asked by At

I need form with one text box and submit button, and that's should be used for taking number from the user and open my site url + the number.

For example: User will type in the text field : 44 Then he press the button. The page should take the number and open a link like this : http://localhost/44

2

There are 2 best solutions below

1
On
<form action='http://example.com'>
    <input type="text" name="number">
    <input type="submit">
</form>
0
On

You have to use jquery + form like below may help you

<form method="get">
<input type="text" name="num" id="num" />
<input type="button" class="submit" value="Go">
</form>


<script type="text/javascript">
$('.submit').live('click',function(){

var url = "http://www.example.com";
var input = $('#num').val();
alert(input);
window.location.href=url+'/'+input;

});
</script>