In the previous module, we learned how to create tables.
In this module, we will learn about forms. Forms allow people to enter information on a webpage. For example, when you register for a game, fill out a school form, or sign up for a website, you are using a form.
A form is a special area on a webpage where users can type information or make choices.
Forms help websites collect information from visitors.
Imagine your teacher gives you a paper asking for your name, age, and favorite subject. That paper is a form. HTML forms work the same way.
We create forms using the <form> tag.
<form> </form>
Everything inside the form tag becomes part of the form.
Text fields allow users to type information.
<form> Name: <input type="text"> </form>
Name: [____________]
Think of a text box as an empty notebook page waiting for someone to write on it.
Radio buttons allow users to choose only one option.
Favourite input type="radio"> Red <input type="radio"> Blue <input type="radio"> Green
You can select only one color.
Imagine choosing one ice cream flavor. You can only pick one flavor at a time.
Checkboxes allow users to select multiple options.
My Hobbies: <input type="checkbox"> Football <input type="checkbox"> Reading <input type="checkbox"> Drawing
You can choose one, two, or all the hobbies.
Imagine choosing toppings for a pizza. You can select as many toppings as you want.
Dropdown lists allow users to choose from a list of options.
<select> <option>Primary 4</option> <option>Primary 5</option> <option>Primary 6</option> </select>
Clicking the dropdown shows all available choices.
A submit button sends information from the form.
<input type="submit" value="Send">
Think of dropping a completed form into your teacher's collection box. The submit button does the same thing.
A reset button clears everything entered into the form.
<input type="reset" value="Clear">
If you make a mistake, the reset button helps you start again.
<!DOCTYPE html>
<html>
<head>
<title>Student Registration Form</title>
</head>
<body>
<h1>Student Registration Form</h1>
<form>
Name:
<input type="text">
<br><br>
Gender:
<input type="radio"> Boy
<input type="radio"> Girl
<br><br>
Hobbies:
<input type="checkbox"> Football
<input type="checkbox"> Reading
<br><br>
Class:
<select>
<option>Primary 4</option>
<option>Primary 5</option>
<option>Primary 6</option>
</select>
<br><br>
<input type="submit" value="Submit">
<input type="reset" value="Reset">
</form>
</body>
</html>
Fill in the blanks:
Create a form that asks for:
Add a Submit button.
Fix the missing tags:
<_____> Name: <input type="text"> <input type="submit" value="Send"> </_____>
Create a webpage called schoolregistration.html.
Include:
Create a "Favorite Things Survey" form.
Include: