I'd like to create a very simple form which has one field where you can e开发者_高级运维nter a 5 digit number - e.g. 12345. When you submit the form, I'd like the page to redirect to http://www.website.com/12345
I'm sure it must be fairly simple, but I've not been able to find the answer anywhere!
Very grateful for any help.
Thanks,
Andrew
There are several things that could be prettier than this (such as extracting it to a function of its own, say) but this is in essence what you want to do.
<form onSubmit=" location.href = 'http://www.website.com/' + document.getElementById('idOfTheTextField').value; return false; ">
If people have JavaScript turned off then this wont work, so really you want something like this:
In PHP -
<?php
$number=$_GET['number'];
header("Location: http://www.yoursite.com/$number");
?>
And your input field should look something like this with 'number' as the name:
<input name="number" value=""/>
精彩评论