Quick question on html forms / url redirection
deicist
Manchester, UK
Righto, I'm working on my very first web app using ruby on rails, and it's all going really well except for this one thing... I'd like a simple form consisting of a text box and a button. The user should enter a number in the box and when the button is clicked it should link to www.mydomain.com/folder/number where number is the number entered in the box. It doesn't need any error checking or anything, just read the number and tag it to the end of the url. I'm sure this should be simple to do but I can't figure it out. Anyone?
0
Comments
I guess it would be safer to just not use a form (is that possible? not sure; at most a dummy form) but only a textbox & button, and have the button's script change your location to a string formed by the desired URL + the text box's contents.
[PHP]<html>
<head>
<script language="Javascript">
function myFunction()
{
document.location.href = "http://www.mydomain.com/folder/" + myForm.myTextBox.value;
}
</script>
</head>
<body>
<form name="myForm">
<input type="text" name="myTextBox" value="">
<input type="button" name="myButton" value="Submit" onClick="myFunction();">
</form>
</body>
</html>[/PHP]