Web Development Lecture 06
Web Development Lecture 06
…… in the previous lecture, we ended with creating a form and doing some basic tasks …. ,
we are continuing from there
<input type = "password"> is a single line text box which hides the characters when entered
by a user.
<!DOCTYPE html>
<html>
<head>
<title>Title goes here</title>
</head>
<body>
<form>
First name:
<input type="text" name="firstname"><br>
<br> Last name:
<input type="text" name="lastname">
<br><input type="submit" value="Submit" >
</form>
</body>
</html>
When you click on reset button on form, it will reset to the default value.
Activity 1
Add Reset and Submit buttons in the form that you created
For example, if we want to create radio buttons that allows a user to select his/her gender,
we have to specify each value separately with <input > tag and the name attribute must
have the same value for each radio button as the following code shows.
The text written after the input tag (i.e. after >) will be displayed after the radio button.
The following code creates a list of radio buttons.
<!DOCTYPE html>
<html>
<head>
<title>Title goes here</title>
</head>
<body>
<form>
<p>From these options, you will select your gender: </p>
Gender:<br>
Activity 2
Add a new field "Movie Type" in the form you create in previous activity .
You should create the following three radio buttons from which a user can select an
option: Comedy, Horror, Action.
This new field should be added just before Reset and Submit buttons on your form.
<!DOCTYPE html>
<html>
<head>
<title>Title goes here</title>
</head>
<body>
<form>
Choose the car do you want to ride:<br>
Choose Option:
<input type="checkbox" name="vehicle1" value="Mercedes">
Mercedes<br>
<input type="checkbox" name="vehicle2" value="Honda"> Honda
<!DOCTYPE html>
<html>
<head>
<title>Title goes here</title>
</head>
<body>
<form>
Birthday:
<input type="date" name="bday">
</form>
</body>
</html>
Activity 3
Add a new field “Release Date” in your form that you created in activity 3. This new field
should be created after the “Movie Type” field on the form. The user should be able to
select a date from the calendar.
<input type="email">
Input type email is used to get email as input from a user. The code below shows how to
get email as input from a user.
<form>
<input type="email" name = "email" >
</form>
Activity 4
Add a field email address in your form that you created in the previous Activity to read
email address of a user
<textarea> </textarea>
The <textarea> tag can be used to create a multi-line text field where a user can write a
long text, such as a comment or a message. This tag has two important attributes:
The following example shows a text area with 4 lines (rows) and 50 characters per line:
<!DOCTYPE html>
<html>
<head>
<title>Title goes here</title>
</head>
<body>
<form action="mypage.html" method="post">
First name:<input type="text" name="fname"><br>
Last name: <input type="text" name="lname"><br>
<textarea rows="4" cols="50">
please write your comment!
</textarea><br>
<input type="submit" value="Submit">
</form>
</body>
</html>
Activity 5
Add a multi-line text area “Feedback” in the form that you created in the previous activity
<select> </select>
A select box, also called a drop down box, provides options as a dropdown list, from where
a user can select an option.
The <select> tag is used to create a dropdown list. Each value in the list is specified using
the <option> tag inside <select> tag.
For example, the following code creates a select box with two values to select from.
<select name="foods">
<option value="pizza">Pizza</option>
<option value="burger">Burger</option>
</select>
The name attribute in <select> tag gives a name to the drop-down list and value attribute
of <option> tag gives a value to each option. The options that appear on the drop-down
list are specified between <option > and </option>.
Select box also called dropdown list are used to select one option from
dropdown list.
<!DOCTYPE html>
<html>
<head>
<title>Title goes here</title>
</head>
<body>
<form action="mypage.html" method="post">
Copyright @ Eugene Tebo NOV 2024
6
SWE_CSN_CWD : – Web Design /.Web Development Notes 06
<datalist></datalist>
This tag is similar to <select> tag. However, there are two major differences between
<datalist> and <select>.
The first one is that <datalist> tag works only with HTML 5. The second difference is that
the <datalist> tag has a small textbox where the user can type a text to search for an item
in the list.
This feature is very important when we have a large list of options to select from.
The following example shows how to create a list of browsers using <datalist> tag.
<!DOCTYPE html>
<html>
<head>
<title>Title goes here</title>
</head>
<body>
<form action="mypage.html" method="post">
<p>Choose your favorite browser from the following browsers
</p>
<input list="browsers">
<datalist id="browsers">
<option value="Internet Explorer">
<option value="Firefox">
<option value="Chrome">
<option value="Opera">
<option value="Safari">
</datalist>
<input type="submit" value="Submit">
</form>
</body>
</html>
Activity 6
Create a datalist “Your favorite Movie type” in your form that you created in activity 6. The
datalist should have the following options to choose from: Horror, Action, Comedy, Drama,
and Musical.
<!DOCTYPE html>
<html>
<head>
<title>Title goes here</title>
</head>
<body>
<form>
First Name:
<input type="text" name="firstname"><br>
<br>Last Name:
<input type="text" name="lastname"><br>
<br>Date of Birth:
<input type="date" name="bday"><br>
<br>Gender :<br>
<input type="radio" name="gender" value="male" checked> Male
<input type="radio" name="gender" value="female"> Female<br>
<br>Email:
<br><br><input type="email" name="email">Qualification
<input type="checkbox" name="matric" value="matric">Matric
<br>
<input type="checkbox" name="fsc" value="intermediate">F.S.C
<br>
<input type="checkbox" name="bsc" value="bachelors">Bsc
<br><br><input type="submit" value="Submit">
<input type="reset">
</form>
</body>
</html>