Page 265 - Beginning PHP 5.3
P. 265
Chapter 9: Handling HTML Forms with PHP
<label for=”submitButton”>A submit button</label>
<input type=”submit” name=”submitButton” id=”submitButton”
value=”Submit Form” />
❑ A reset button — This type of button resets all form fields back to their initial values (often
empty). The value attribute contains the button label text:
<label for=”resetButton”>A reset button</label>
<input type=”reset” name=”resetButton” id=”resetButton”
value=”Reset Form” />
❑ A file select field — This allows the users to choose a file on their hard drive for uploading to the
server (see “Creating File Upload Forms” later in the chapter). The value attribute is usually
ignored by the browser:
<label for=”fileSelectField”>A file select field</label>
<input type=”file” name=”fileSelectField” id=”fileSelectField”
value=”” />
❑ A hidden field — This type of field is not displayed on the page; it simply stores the text value
specified in the value attribute. Hidden fields are great for passing additional information from
the form to the server, as you see later in the chapter:
<label for=”hiddenField”>A hidden field</label>
<input type=”hidden” name=”hiddenField” id=”hiddenField” value=”” />
❑ An image field — This works like a submit button, but allows you to use your own button
graphic instead of the standard gray button. You specify the URL of the button graphic using the
src attribute, and the graphic’s width and height (in pixels) with the width and height
attributes. As with the submit button, the value attribute contains the value that is sent to the
server when the button is clicked:
<label for=”imageField”>An image field</label>
<input type=”image” name=”imageField” id=”imageField” value=””
src=”asterisk.gif” width=”23” height=”23” />
❑ A push button — This type of button doesn’t do anything by default when it’s clicked, but you
can make such buttons trigger various events in the browser using JavaScript. The value
attribute specifies the text label to display in the button:
<label for=”pushButton”>A push button</label>
<input type=”button” name=”pushButton” id=”pushButton”
value=”Click Me” />
❑ A pull-down menu — This allows a user to pick a single item from a predefined list of options.
The size attribute’s value of 1 tells the browser that you want the list to be in a pull-down menu
format. Within the select element, you create an option element for each of your options.
Place the option label between the <option> ... </option> tags. Each option element can
have an optional value attribute, which is the value sent to the server if that option is selected. If
227
9/21/09 7:23:34 PM
c09.indd 227
c09.indd 227 9/21/09 7:23:34 PM