[Javascript] Opening an URL through a form

Hassan Schroeder hassan at webtuitive.com
Sat May 3 17:09:37 CDT 2003


LJ wrote:

> I'd like to create a HTML form where the word entered in a text field
> will be added to the following url that will be opened on submit
> http://www.google.com/search?hl=sv&ie=UTF-8&oe=UTF-8&q=
> 
> I.e., if you enter "hello" in the text field submitting the form will
> open the url http://www.google.com/search?hl=sv&ie=UTF-8&oe=UTF-8&q=hello

You're in luck -- that's the way browsers work; a 'GET' request
has all form name/value pairs appended as a 'query string' :-)

<form method="get" action="http://www.google.com/search">
<input type="hidden" name="hl" value="sv"/>
<input type="hidden" name="ie" value="UTF-8"/>
<input type="hidden" name="oe" value="UTF-8"/>
<input type="text" name="q"/>
<input type="submit"/>
</form>

In other words, the above form will do exactly what you describe.

HTH!
-- 
Hassan Schroeder ----------------------------- hassan at webtuitive.com
Webtuitive Design ===  (+1) 408-938-0567   === http://webtuitive.com

                           dream.  code.





More information about the Javascript mailing list