Java Reference
In-Depth Information
A Searching Example
We'll start off with a simple example of a form that contains one input field and a button
to submit a search query, not unlike the one used by Google. This example doesn't use any
styles; you just need to create a file called index.htm that contains the following code:
index.htm
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Search</title>
</head>
<body>
<form name="search" action="search">
<input type="text" name="searchBox">
<button type="submit">Search</button>
</form>
<script src="scripts.js"></script>
</body>
</html>
This form has a name attribute of " search " and contains two controls: an input field where
a user can enter a search phrase and a button to submit the form. The form can also be sub-
mitted by pressing Enter .
The " action " attribute is the URL that the form will be submitted to so that it can be pro-
cessed on the server side. The input field also has a " name " attribute of " searchBox " that
is used to access the information inside it.
You should also create a file called scripts.js to put the JavaScript in. This can be saved in
the same directory as index.htm.
Search WWH ::




Custom Search