Form Components and Elements First Name Address #1 Address #2 City Last Name Country State Zip Item Purchased Purchase Date Home Business Government Educational Institution Netware Banyan Vines Windows IBM Lan Server Comments?: Send Registration Cancel Serial Number Used For (check one) Network Operating System (check all that apply) Religious or Charitable Institution PC/NFS text box drop-down list box radio buttons check boxes text area form button group box This figure shows a form that contains various control elements commonly used in Web page forms.
Input boxes Accept user inputs (~ form fields) Text (default) Password Radio (one selection only) Checkbox (multiple selection is allowed) Selection list Text Area
Input boxes Perform actions Submit Reset Button Others Hidden
Form objects 1. Input text box document.form_name.field_name e.g., document.Registration.FirstName Properties: value: what is being entered? value.length: how many characters are being entered? Methods: indexOf(“character): returns the relative location of the character within the text entered Events: focus(): moving the cursor into the field Event handlers: onBlur: when the user left the field
Form objects 2. Selection list document.form_name.field_name e.g., document.Registration.State Properties: selectedIndex: the index value of the currently selected option in the list (starts with 0) options[index].value: returns the value property of an option in a selection list options[index].text: returns the text (shown to the user) in a selection list
Form objects 3. checkboxes e.g., document.Registration.brkfst document.form_name.field_name e.g., document.Registration.brkfst Properties: checked: returns true if the checkbox is selected else returns false
Form objects 4. Radio button e.g., document.Registration.meal[0] document.form_name.field_name[index] e.g., document.Registration.meal[0] Properties: checked: returns true if the button is selected else returns false
Form objects 5. Input button 6. Entire form Event handler: onClick onSubmit