Professional Documents
Culture Documents
WEB ENGINEERING
LECTURE N0. 7
INSTRUCTOR: MS. MEHAK SHEIKH
Div
2
HTML FORMS
What are forms?
4
Most, but not all, form elements use the input tag, with a
type="..." argument to tell which kind of element it is
type can be text, checkbox, radio, password, hidden, submit, reset,
button, file, or image
Other common input tag arguments include:
name: the name of the element
value: the “value” of the element; used in different ways for different
values of type
readonly: the value cannot be changed
disabled: the user can’t do anything with this element
Other arguments are defined for the input tag but have meaning only
for certain values of type
Text input
7
A text field:
<input type="text" name="textfield" value="with an initial value">
A password field:
<input type="password" name="textfield3" value="secret">
• Note that two of these use the input tag, but one uses textarea
Buttons
8
A submit button:
<input type="submit" name="Submit" value="Submit">
A reset button:
<input type="reset" name="Submit2" value="Reset">
A plain button:
<input type="button" name="Submit3" value="Push Me">
A checkbox:
<input type="checkbox" name="checkbox”
value="checkbox" checked>
type: "checkbox"
name: used to reference this form element from JavaScript
value: value to be returned when element is checked
Note that there is no text associated with the checkbox—you
have to supply text in the surrounding HTML
Radio buttons
10
Radio buttons:<br>
<input type="radio" name="radiobutton" value="myValue1">
male<br>
<input type="radio" name=" radiobutton " value="myValue2" checked>
female
If two or more radio buttons have the same name, the user
can only select one of them at a time
This is how you make a radio button “group”
Drop-down menu or list
11
A menu or list:
<select name="select">
<option value="red">red</option>
<option value="green">green</option>
<option value="BLUE">blue</option>
</select>
Additional arguments:
size: the number of items visible in the list (default is "1")
Hidden fields
12
<html>
<head>
<title>Get Identity</title>
</head>
<body>
<p><b>Who are you?</b></p>
<form method="post" action="">
<p>Name:
<input type="text" name="textfield">
</p>
<p>Gender:
<input type="radio" name="gender" value="m">Male
<input type="radio" name="gender" value="f">Female</p>
</form>
</body>
</html>
Grouping Form Data with <fieldset>
14
<form>
<fieldset>
<legend>Personalia:</legend>
Name: <input type="text"><br>
Email: <input type="text"><br>
Date of birth: <input type="text">
</fieldset>
</form>
HTML Input Attributes
16
Example
HTML form
20
<html><body><form>
<h1>Create a Internet Mail Account</h1>
<p>First Name <input type="text" name="T1" size="30"></p>
<p>Last Name <input type="text" name="T2" size="30"></p>
<p>Desired Login Name <input type="text" name="T3" size="20">
@mail.com</p>
<p>Password <input type="password" name="T4" size="20"></p>
<input type="radio" checked="checked" name="gender" value="male" /> Male</br>
<input type="radio" name="gender" value="female" /> Female
<p>Birthday <input type="text" name="T6" size="05">
<select size="1" name="D2">
<option>-Select One-</option>
<option>January</option>
<option>February</option>
<option>March</option> </select>
<input type="text" name="T7" size="10"></p> TypeYourself<textarea rows="4" name="S1"
cols="20"></textarea>
<br><input type="submit" value="Accept" name="B1"> <input type="reset " value="Cancel"
name="B2"></br> </form></body></html>
21
The autofocus attribute of <input>
22
HTML5 <datalist> Tag
The <datalist> tag specifies a list of pre-defined
options for an <input> element.
The <datalist> tag is used to provide an
"autocomplete" feature on <input> elements.
Users will see a drop-down list of pre-defined
options as they input data.
Use the <input> element's list attribute to bind it
together with a <datalist> element.
New Elements in HTML5
26
HTML5 <datalist> Tag
<input type="text" list="browsers"
name="browser" />
<datalist id="browsers">
<option value="Internet Explorer">
<option value="Firefox">
<option value="Chrome">
<option value="Opera">
<option value="Safari">
</datalist>
New Elements in HTML5
27
HTML5 <details> Tag
The <details> tag specifies additional details that
the user can view or hide on demand.
The <details> tag can be used to create an
interactive widget that the user can open and close.
Any sort of content can be put inside the <details>
tag.
New Elements in HTML5
28
HTML5 <details> Tag
<details>
<summary>Copyright 1999-2011.</summary>
<p> - by Refsnes Data. All Rights Reserved.</p>
<p>All content and graphics on this web site are
the property of the company Refsnes Data.</p>
</details>
New Elements in HTML5
29
HTML5 <mark> Tag
The <mark> tag defines marked text.
Use the <mark> tag if you want to highlight parts
of your text.
<html>
<body>
<p>Do not forget to buy <mark>milk</mark>
today.</p>
</body>
New Elements in HTML5
30
HTML5 <progress> Tag
Use the <progress> tag in conjunction with
JavaScript to display the progress of a task.
<progress value="22" max="100"></progress>
HTML5 Video
31
Question???