Java Reference
In-Depth Information
Form Buttons
There are several types of form buttons that web servers can make use of. The HTML
necessary to create each of these button types is shown here.
<input type="button" name="button" value="Button">
<input type="image" name="image" value="Image"
src="/images/button.png">
<input type="reset" name="reset" value="Reset">
<input type="submit" name="submit" value="Submit">
The most commonly used are the image button and the submit button. The image
button allows you to create a button that looks like any image that you choose. The regular
submit button looks like an ordinary button. Both of these button types will submit the
form.
The reset button type does not send any data back to the web server. Rather, the
reset button simply resets all of the form data back to their default values. Reset buttons
are not seen on web forms nearly as often as they used to be.
The button type attribute is used with JavaScript. JavaScript can be difficult to cre-
ate a bot for. JavaScript will be covered in Chapter 9, “Handling Javascript”.
The name attribute of the buttons specifies the name of the button. The name is not
displayed to the user. However, the name attribute is very important, because it gives the
web server a name to identify the button.
The value attribute specifies the text of the button that is displayed to the user. Ad-
ditionally, the value attribute is returned, along with the name to allow the web server to
further identify the button. For example, consider the following buttons:
<input type="submit" name="action" value="Button1">
<input type="submit" name="action" value="Button2">
If the user were to click “Button 1”, the following data would be returned to the web
server:
action=Button1
This is how data is always returned to the web server, as name-value pairs. This allows
you to have more than one button named the same thing. For example, the above two but-
tons are both named action . If the user were to click Button2 , the following would be
returned to the web server.
action=Button2
This is called a name-value pair. All data returned from HTML forms will be returned as
name-value pairs.
Search WWH ::




Custom Search