DRILL10
DRILL10
1. Identify
the type of form controls you’re going to insert in your HTML page.
2. Use the<form>…</form> element to create a form.
3. Use thefollowing elements in inserting form controls:
1. <input /> - use to define input types like text, password, checkbox, radio, submit, reset, file,
hidden, image, and button.
2. <select>…</select> - inserts a selection control for the user to select one or more options.
3. <textarea>…</textarea> - inserts a multi-line text input area for use in a form.
4. <button>…</button> - inserts a push button for use in a form or to start a script.
Note:
Required Attribute of a form
Attribute Values Description
action URL The URL of the form handler, typically a script file or Java servlet.
method="post" sends the form data as an HTTP POST request. POST does not have the
character encoding and length restrictions imposed by GET, but most browsers are unable
to bookmark POST requests.
Authors should generally only use a different enctype when the form includes a type=file
input element, in which case the enctype should be "multipart/form-data" and the
method must be "post".
Specifies a list of character encodings that are accepted by the form handler. The value
accept- consists of a list of charsets separated by commas and/or spaces. The default value is
CharSets
charset "unknown" and is usually considered to be the character encoding of the document
containing the form.
Specifies the frame (of a frameset) the form response should be displayed in. If no frame
target FrameTarget
with such a name exists, the response is displayed in a new window.
Element-Specific Events of a form
Event Trigger
onsubmit when the form is submitted
onreset when the form is reset
When type is "checkbox" or "radio": Specifies the value of the control when
checked. Value must be specified for these controls.
value CDATA When type is "submit", "reset", or "button": Specifies the button label.
When type is "file": Specifies the default filename. Browsers typically ignore
this as a security precaution.
checked [none] Specifies that a radio button or checkbox control is initially checked.
size Number Specifies the size, in number of characters, of a text or password field.
Specifies the maximum number of characters that can be entered in a text
maxlength Number
or password field.
src URL The URL of an image file (only used when type="image").
alt CDATA Specifies alternate text when type="image".
usemap URL The URL of a map definition to use when type="image". Poorly supported.
top
Specifies how to align an image button with respect to surrounding text.
middle
"Top", "middle", and "bottom" position the image vertically with respect to
align bottom
the current line (of text, usually). "Left" and "right" specify that the image is
left
placed at the left or right margin, with other content flowing around it.
right
Disables the input control. Disabled controls cannot receive focus, and their
disabled [none] values are not submitted with the form. Cannot be used with
type="hidden".
Prevents users from changing the value of an input control. The value is still
readonly [none]
submitted with the form. Only used with type="text".
A comma-separated list of media types to be accepted when type="file".
accept ContentTypes Generally ignored by browsers.
Specifies a single character as a shortcut key to give focus to the input
accesskey Character
control. Not applicable when type="hidden".
Specifies the tabbing order of the control. The lower the number, the earlier
the control is in the tabbing sequence of the document. If tabindex=0 or is
tabindex Number not defined, the control comes after any elements with a positive tabindex.
Not applicable when type="hidden".
• If the multiple attribute is present but size is not specified, some browsers will auto-size the selection control
large enough to display all the available options at once. To avoid an excessively tall selection box, be sure to
specify size.
Example 1
<p style="margin-left:0">Operating System:</p>
<select name="os">
<option>Windows XP</option>
<option>Windows 2000</option>
<option>Windows Me</option>
<option>Windows 98</option>
<option>Windows 95</option>
</select>
A simple selection control rendered as a drop-down menu.
Here's how the HTML above might render in a browser:
Example 2
<p>Operating System:</p>
<select name="os" size="5" multiple>
<optgroup label="Microsoft">
<option>Windows XP</option>
<option>Windows 2000</option>
<option>Windows NT</option>
<option>Windows Me</option>
<option>Windows 98</option>
<option>Windows 95</option>
</optgroup>
<optgroup label="Macintosh">
<option>OS X</option>
<option>OS 9</option>
</optgroup>
</select>
A selection group using optgroup elements and allowing multiple selections.
Example 1
<button name="submit" value="modify">
<b><i>Modify Info</i></b>
</button>
Unlike buttons created using the input element, button elements can enclose other HTML tags.
Example 2
<button type="button" onclick="myscript()">
<img src="mybutton.gif" />
</button>
This button uses a graphical label.
Drill 10.1: FORMS in NO Arrangement
Text Field
Radio Button
Select Menu
Text Field
Select Menu
Textarea
Text Field
Password
Submit Button
Reset Button
Fieldset
Instruction for Drill 10
1. Create a New HTML page and name it Drill10_FORMS_Yourname.
2. Perform the Drill as shown below.
3. Save the File and open it in any WEB BROWSER (i.e Internet Explorer, Mozilla Firefox, Google Chrome,
Opera, Safari, and etc.) available in computer system.
NOTE: As you save your HTML document, don’t forget to refresh or reload your Web Browser.
EVALUATION CITERIA
Organization and Clarity (code & design) 15 pts
Conformity to the Requirements 20pts
Accuracy and Reliability 15pts
TOTAL 50pts
Checkbox
File