HTML Forms

From CSE330 Wiki
Revision as of 06:16, 16 March 2013 by Shane (talk | contribs) (Created page with 'The contents of a web page often changes depending on how you requested that page. For example, when you perform a web search, the contents of the search list changes depending …')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

The contents of a web page often changes depending on how you requested that page. For example, when you perform a web search, the contents of the search list changes depending on your query. This is done by way of HTTP request variables (aout which you will learn more in Module 2).

The most fundamental way to make a web page sent HTTP request variables to another page is by using HTML Forms. This article describes this process and how to implement it in your code.

HTTP Request Variables

Visit your favorite search engine, and search for "QUERY". Now, look at your address bar. Can you find your query "QUERY" somewhere up there?

Your search engine probably used an HTTP Request Variable to send your desired query to the search page. Here is how it might have worked:

HTMLForm.png

You can see that we didn't just go to example.com/search; we also incorporated the search query into the query string of the URL, where query stream

Code Example

The syntax for making a form in HTML is relatively straightforward:

<form action="ACTION" method="GET">
	<input type="text" name="q" />
	<input type="submit" value="Search" />
</form>

where ACTION is the URL of your destination page, with no query strings. (