Professional Documents
Culture Documents
Cs101 Lec12
Cs101 Lec12
Lecture 12
Interactive Forms
(Web Development Lecture 4)
1
Focus of the last lecture was on
HTML Lists & Tables
• We learnt how to extend our Web pages by
adding a few more tags
3
Interactive Forms (1)
• Without forms, a Web site is “read-only” – it
just provides information to the user
5
Interactive Forms (3)
• Are GUI-based
• May contain:
– Text fields
– Check boxes
– Buttons
– Scrollable lists
6
A Simple
Example
of
Interactive
Forms
7
Code for that Example
<HTML>
<HEAD>
<TITLE>Send Email to me</TITLE>
</HEAD>
<BODY>
<H1>Send Email to me</H1>
Code for the instructions
Code for the form
</BODY>
</HTML>
8
A Simple
Example
of
Interactive
Forms
9
Code for the Instructions
<OL>
<LI>Type your eMail address in the
"From" field</LI>
<LI>Type a short message in the
"Message" field</LI>
<LI>Press the "Send eMail to
me" button</LI>
</OL> 10
A Simple
Example
of
Interactive
Forms
11
Code for the Form
</FORM>
12
<FORM name="sendEmail" method="post"
action="sendMailScriptURL">
Elements of the form
</FORM>
• Examples:
– CGI scripts on Unix servers
– ASP scripts on Windows servers
14
A Simple
Example
of
Interactive
Forms
15
Elements of the Form (1)
<P>From: <INPUT type="text"
name=“sender" size="50"></P>
16
A Simple
Example
of
Interactive
Forms
17
Elements of the Form (2)
<P><INPUT type="hidden" name="receiver"
value="altaf@vu.edu.pk"></P>
18
A Simple
Example
of
Interactive
Forms
19
20
21
22
<TEXTAREA
name=“message”
cols=“38”
rows=“6”
>
</TEXTAREA>
23
<FORM name="sendEmail" method="post" action=“sendMailScriptURL">
<table><tr>
<td>From: </td>
<td><INPUT type="text" name="sender" size="50"></td>
</tr><tr>
<td>To: </td>
<td><INPUT type="text" name="receiver" size="50"></td>
</tr><tr>
<td>Subject: </td>
<td><INPUT type="text" name="subject" size="50"></td>
</tr><tr>
<td valign="top">Message: </td>
<td><TEXTAREA name="message" cols="38"rows="6">
</TEXTAREA></td>
</tr><tr>
<td colspan="2" align="right">
<INPUT type="submit" name="sendEmail" value="Send eMail">
</td>
</tr></table> 24
</FORM>
25
<INPUT
type=“text”
name=“sender”
size=“50”
value=“your eMail address goes here”
>
26
Review of the Tags Used in Forms
27
<FORM
name=“nameOfTheForm”
method=“get” or “post”
action=“URL”
>
</FORM>
28
Single-Line Text Input Field
<INPUT
type=“text”
name=“fieldName”
size=“widthInCharacters”
maxlength=“limitInCharacters”
value=“initialDefaultValue”
>
29
Hidden Input
<INPUT
type=“hidden”
name=“fieldName”
value=“value”
>
30
Submit Button Input
<INPUT
type=“submit”
name=“buttonName”
value=“displayedText”
>
31
Multi-Line Text Input Area
<TEXTAREA
name=“areaName”
cols=“widthInCharacters”
rows=“numberOfLines”
>
initial default value
</TEXTAREA>
32
This was a review of the new tags
(and associated attributes) that we
have used in today’s examples
33
34
<form name="login" method="post" action="loginScript">
<table><tr>
<td>User Name: </td>
<td>
<input type="text" name="userName" size="10">
</td>
</tr><tr>
<td>Password: </td>
<td>
<input type="password" name="password" size="10">
</td>
</tr><tr>
<td colspan="2" align="right">
<input type="submit" name="login" value="Log me in">
</td>
</tr></table> 35
</form>
Password Input Field
<INPUT
type=“password”
name=“fieldName”
size=“widthInCharacters”
maxlength=“limitInCharacters”
value=“initialDefaultValue”
>
36
37
<form name="login" method="post" action="loginScript">
<table><tr>
<td>User Name: </td>
<td>
<input type="text" name="userName" size="10">
</td>
</tr><tr>
<td>Password: </td>
<td>
<input type="password" name="password" size="10">
</td>
</tr><tr>
<td colspan="2">
<input type="checkbox" name="remember" value="remember">
Remember my user name and password<br>
</td>
</tr><tr>
<td colspan="2">
<input type="submit" name="login" value="Log me in">
</td>
</tr></table> 38
</form>
Checkbox Input Element
<INPUT
type=“checkbox”
name=“checkboxName”
checked
value=“checkedValue”
>
39
Office
40
<form name="login" method="post" action="loginScript">
<table><tr>
<td>User Name: </td>
<td>
<input type="text" name="userName" size="10">
</td>
</tr><tr>
<td>Password: </td>
<td>
<input type="password" name="password" size="10">
</td>
</tr><tr>
<td valign="top">Logging in from:</td>
<td>
<input type="radio" name="from" value="home"> Home<br>
<input type="radio" name="from" value="office"> Home<br>
<input type="radio" name="from" value="university" checked> University
</td>
</tr><tr>
<td colspan="2" align="right">
<input type="submit" name="login" value="Log me in">
</td>
</tr></table> 41
</form>
Radio Button Input Element
<INPUT
type=“radio”
name=“radioButtonName”
checked
value=“selectedValue”
>
42
What is the difference between
checkboxes and radio buttons?
43
44
<form name="login" method="post" action="loginScript">
<table><tr>
<td>User Name: </td>
<td><input type="text" name="userName" size="10"></td>
</tr><tr>
<td>Password: </td>
<td>
<input type="password" name="password" size="10">
</td>
</tr><tr>
<td valign="top">Logging in from:</td>
<td>
<select size="2" name="from">
<option value="home"> Home
<option value="office"> Office
<option value="university" selected> University
</select>
</td>
</tr><tr>
<td colspan="2">
<input type="submit" name="login" value="Log me in">
</td>
</tr></table> 45
</form>
Select from a (Drop Down) List
<SELECT
name=“listName”
size=“numberOfDisplayedChoices”
multiple
>
<OPTION value=“value1”> text1
<OPTION value=“value2” selected> text2
<OPTION value=“value3”> text2
…
…
</SELECT> 46
47
File Upload Input Element
<INPUT
type=“file”
name=“buttonName”
value=“nameOfSelectedFile”
enctype=“fileEncodingType”
>
48
<form
name=“uploadForm”
method=“post”
action=“uploadScript”
<input
type=“file”
name=“uploadFile”
enctype=“multipart/form-data”
>
<input
type=“submit”
name=“submit”
value=“Upload”
> 49
</form>
Reset Button Input Element
(Resets the contents of a form to default values)
<INPUT
type=“reset”
value=“dispalyedText”
>
50
51
Assignment # 4
Create a simple Web page to provide electronic
greeting message service on the Internet. Your
Web page should contain:
a. The heading of the Web page
b. Input fields to capture information (i.e. names
and email addresses) about the sender and
the receiver of the message
c. List of the available greeting messages
d. Button to send the card
53
Next Web Dev Lecture:
More Complex Form
• Today we started our discussion on interactive
forms