Lab 5
Lab 5
Lab 5
HTML Forms
Entering User Data from a Web Page
Forms are the primary method for gathering data from site visitors
<form></form>
The “method" attribute tells how the form data should be sent – via GET or POST
request
The "action" attribute tells where the form data should be sent
action="path/to/some-script.php">
...
</form>
<fieldset>
<legend>Client Details</legend>
</fieldset>
<fieldset>
<legend>Order Details</legend>
</fieldset>
</form>
Checkboxes:
Radio buttons:
Radio buttons can be grouped, allowing only one to be selected from a group:
<input type="radio" name="city" value="Lom" />
Dropdown menus:
<select name="gender">
<selected="selected">Male</option>
</select>
Submit button:
Image button – acts like submit but image is displayed and click coordinates are sent
Password input – a text field which masks the entered text with * signs
Multiple select field – displays the list of items in multiple lines, instead of one
<selected="selected">keyboard</option>
</select>
File input – a field used for uploading files
<form enctype="multipart/form-data">
...
...
</form>
Form labels are used to associate an explanatory text to a form field using the field's ID.
Clicking on a label focuses its associated field (checkboxes are toggled, radio buttons are
checked)
Labels are both a usability and accessibility feature and are required in order to pass
accessibility validation.
<fieldset><legend>Academic information</legend>
<label for="degree">Degree</label>
Business Administration</option>
</select>
<br />
<label for="studentid">Student ID</label>
</fieldset>
<fieldset><legend>Personal Details</legend>
<br />
<br />
Gender:
<label for="gm">Male</label>
<label for="gf">Female</label>
<br />
<label for="email">Email</label>
</fieldset>
<p>
</p>
<p>
</form>