HTML and CSS Reference
In-Depth Information
figure 6-62
accessing a data list of options
suggested text string to
complete the text box
4. Continue to type in letters from the selected data list to verify that the suggested
food items change to reflect your text entry.
Now that you've completed all of the fields for the survey form, you'll next examine
how to submit the form for processing. To do that, you'll create a form button.
Creating Form Buttons
So far, all of your control elements have involved entering field values. Another type of
control element is one that performs an action. In forms, this is usually done with form
buttons , each of which performs one of three actions:
• Run a command from a program linked to the Web page.
• Submit the form to the program running on the server.
• Reset the form to its starting values.
The first type of button you'll examine is the command button.
Creating a Command Button
A command button runs a command that affects the contents of the Web page or the
Web browser itself. Command buttons are created by applying the button attribute to
the input element
<input type=”button” value=” text ” />
where text is the text that appears on the button. To associate an action with a com-
mand button, you link the button to a program that runs when the command button is
clicked using the onclick attribute, as follows
<input type=”button” value=” text ” onclick=” program ” />
where program is the name of the program. In most cases, the program is stored in a
JavaScript file that is linked to the Web page. For example, the input element
<input type=”button” value=”Run Program” onclick=”setup()” />
creates a command button that runs the JavaScript program setup() when the button is
clicked. You won't be applying command buttons to the survey page.
Search WWH ::

Custom Search