PDA

View Full Version : Submit Button with text box


-Aaron-
01-13-2006, 07:31 AM
hello all,

does anyone know a basic hmtl code that will allow a user to type something into a text box and when the user clicks on the submit button making it go to a website..

like if a user types in 'hello' in a text box and then clicks on the submit button making it go to a site like 'http://www.example.com/?url=hello'

i want to make it so that the URL + what ever the user types in goto a page.
(eg. http://www.example.com/?url= + what ever is entered in the text box)

i can't found out how to do it anyone know how?

aluminumpork
01-13-2006, 07:32 PM
Here ya go:


<html>
<head>
<script type="text/javascript">
<!--
var mainUrl = 'http://www.yoursite.com/?url=';

function redirect(){
var url = document.getElementById('urlText').value;
mainUrl = mainUrl + url;
window.location.href = mainUrl;
}

//-->
</script>
</head>

<body>
<form name="pageRedirect">
<input type="text" id="urlText" name="urlText" />
<input type="button" value="Go!" onClick="redirect();" />
</form>

</body>
</html>


It should work, hope it helps!