<html>
<head>
<script type="text/javascript">
function submit() {
var queryField = document.getElementById("queryField");
document.location.href = document.location.href + "/query/" +
queryField.value;
return false;
}
</script>
</head>
<body>
<form onsubmit="return submit();">
<input name="query" id="queryField">
<input type="submit">
</form>
</body>
</html>
This is my script/HTML page. I am just trying to do this:
The user goes to www.mysite.com. There is an input box and a submit
button. They enter text into the input box (ie "john") and hit submit.
I now want to redirect them to www.mysite.com/query/john instead of
www.mysite.com/?query=john. I thought this script would do it but it
does not.
I think it is something to do with the onsubmit= thing. Because this
has worked if I just trap onclick on the button. But then if you press
return/enter on the search field it will not work. Any ideas?
Thanks in advance.
-Steve