Computer Highlight ch-1
Computer Highlight ch-1
With increase in the use of Internet many activities have become online. We may use
a web page
to fill information about ourselves or a product. HTML forms are used to help the
visitors of the
website to input data. It allows for more interactivity and control in data entry.
For instance, if you
want to open a mail account or register on a website, you need to enter your
personal details in
a form. This information is used to setup the account for the user. In order to
obtain such information
on Internet, HTML forms are used. This data is further stored by the application
and used to retrieve
the details about the users registered on the website.
A form in HTML is a container used to collect different kinds of inputs from the
user. HTML forms
contains elements like label, checkbox, text input field, radio button, submit
button, reset button and many
more. These elements are used to enter the data as well as validate the data within
the forms. We will
create a sumple form to enter the data using HTML tags, but before that let us
discuss about the elements
used to create HTML forms. The elements used are described in the section below :
e Form
e Input
e Textarea
The form element is used to create an HTML form. It acts as a container for all the
elements used
in the form. The tag <form>... </form> is used to implement this element. The
example shows
the use of the form element :
</form>
Observe that the form element uses two attributes namely action and method. The
action attribute is used
to specify where to send the form data when the form is submitted. It takes a
filename as value. This file
is opened when the user clicks on the submit button after filling the data in the
form.
The method attnbute specifies the HTTP method to be used when sending the data. It
can take
Creating HTML forms using KompoZer 1
two values; GET and POST. The GET method retrieves the data from the form and sends
it to
the server by attaching it at the end of the URL. This method allows only a limited
amount of
information to be sent at a time. In the POST method, the data is sent as a block
through the
HTTP transaction. The data is included in the body of the request. This method does
not have
any restrictions on data length. The default value for method attribute is GET.
Input element
The input elements are used to insert various fields like radio button, text box
and checkbox in
the form. The tag <input> ....</input> or <input> is used to implement this
element. The input tag
has different attributes like type, name and value.
The type attribute of the input element specifies the field that is to be created
in the form. The
name attribute specifies the name to be used for the field in the form. The value
attribute specifies
the default value of the field in the form. Table 1.1 shows different values of
attribute and its usage.
Radio Creates radio buttons in the form. Any oneradio | <INPUT TYPE = "radio" NAME
button can be selected at atime fromagroupof | = “var" VALUE = "txt">
of items.
Text Creates a text field to enter textin the form.A | <INPUT TYPE = "text" NAME
user can enter any data of his choice in the | = “var” VALUE = "txt" >
text field.
Submit Creates a submit button inthe form. Onclicking | <INPUT TYPE = “submit”
the submit button, the values of data enteredin | VALUE = "label" >
Reset Creates a reset button in the form. On clicking | <INPUT TYPE = "reset" VALUE
the reset button, the values of dataenteredinthe | = "Jabel" >
form are cleared and set back to default values.
Table 1.1: Values of Type attribute used with input tag
2 Computer Studies : 12
Textarea element
The Textarea element allows multi-line text input. The tag <textarea>...</textarea>
is used to implement
this element. It allows entering unlimited number of characters. It can be used to
enter comment,
report or a long description of product. The size of a textarea element can be
specified using rows
and cols attributes. The rows attribute is used to set the number of rows of text
that will be visible
without scrolling up or down. The cols attribute is used to set the number of
columns of text that
will be visible without scrolling right or left. The following example shows how to
insert a textarea
in the form.
The select element is used to create a drop down list or menu in a form. The option
element is
used to specify the values that are to be displayed in the menu. The tag
<select>....</select> is
used to create a drop down menu. The tag <option>...</option> is used to create the
elements
within the menu. Following example shows the use of select and option element.
<select>
<option value="A hmedabad" >Ahmedabad</option>
<option value="Rajkot" >Rajkot</option>
<option value="Surat" >Surat </option>
</select>
Let us now create a sample registration form using the elements learned so far.
Code listing 1.1
shows the HTML source code used to generate the form. The output of the code is
shown in
figure 1.1.
<HEAD>
<TITLE>Registration Form</TITLE>
</HEAD>
<BODY bgcolor="lightblue">
<hl> <center>Registration Form</center></h1>
<FORM name="frmRegistration" action="form.html">
<center>
<TABLE BORDER="0">
<TR>
<TD width="12%">First Name</TD>
<TD width="1%">é </TD>
4 Computer Studies : 12
Highlighted by Pragati Computers, M. 99041676771.
<Select Name="cmbCity">
<Option >Ahmedabad</Option>
<Option >Baroda</Option>
<Option selected>Rajkot</Option>
<Option >Surat</Option>
</Select>
</TD>
</TR>
<TD> </TD>
<TD> </TD>
<TD> <INPUT type="submit” name="cmdSubmit" value="Submit">
<INPUT type="reset" name="cmdReset" value="Reset">
</TD>
</TR>
</TABLE>
</center>
</FORM>
</BODY>
</HTML>
Registration Form
First Name
Middle Name
Last Name
Address
City fajkat
Supmet, | Reset
Thus, you can see that creating a form using HTML tags is a tedious process. A
simpler method
is to use an IDE (Integrated Development Environment). An IDE is a software
application that provides
complete facilities to programmer to develop software. It provides a GUI (Graphical
User Interface),
text or code editor, a compiler and/or interpreter and a debugger. KompoZer,
Eclipse, JBuilder and
Netbeans are all examples of some open source IDEs. Let us discuss how to use the
KompoZer
to create web pages.
Introduction to KompoZer
KompoZer is a free open source web development IDE. It can be downloaded from
http://
www.KompoZer.net. It provides a web page editor which has a simple graphical
interface known
as WYSIWYG "what you see is what you get". It is a complete web authoring system.
which integrates
web page development and web file management. Creating new web pages using Kompo/er
is
quick and easy. The users can also edit the web pages by using the source code and
making changes.
KompoZer incorporates a Site Manager which gives rapid access to the files on both
local machines
and remote servers. Web pages and associated files can be uploaded to a remote
server from within
KompoZer. It also supports the use of "Styles" through Cascading Style Sheet (CSS).
We will learn
about CSS in the next chapter.
Before we learn how to create forms using KompoZer, let us first learn the KompoZer
interface.
Open KompoZer by locating its icon. To view the different toolbars and status bar
(if not visible)
click on View > Show/Hide. Select all the options listed: Composition Toolbar,
Format Toolbar1,
Format Toolbar2, Edit Mode Toolbar and Status bar. Site Manager and Rulers option
should also
be checked. Figure 1.2 shows the window that will be displayed after selecting the
toolbars.
Menu bar ——7"" [de Yew iuet -Fgemat Tele Tosh Hel
Composition Toolbar —— - | ws PY Lp db ann. aoe @
Farmat Toolbart _ : i : an a :
Format Toolbar? | a ita , 2
verabiaewieth or |W 4 |g ! EnZS
Page tab snag : =
+ Sih Png ee Te | a
Rulers eT at! ie : T
ao a ea TF 1
Site Manager
Page Area
FTP creme!
© DOR tages ee ee || fay al
|
|
Status bar Edit mode Toolbar
Observe that in figure 1.2 you can see the menu bar on the top with the options
like File, Edit,
View, Insert, Format, Table, Tools and Help. Below the menu bar there are three
Toolbars:
Composition, Format Toolbar] and Format Toolbar2.
The composition toolbar is used to create new file, open a file, save a file or
publish a web page.
The Format toolbar! and Format toolbar? are used to format the text, add bullets,
numbering and
perform similar formatting operations.
6 Computer Studies : 12
can also click on File > Open. If the file has been opened recently, then you can
also open
the file from File > Reeent Pages.
Now let us learn to create a forms using KompoZer. We will create a simple form
with two input
fields: Name and E-mail address and a submit button. Follow the steps given to
create the form.
e From the menu bar, select Insert > Form > Define Form. Alternatively, you can
also click
on * in the composition toolbar. This will open a Form Properties dialog box as
shown
Focm
in figure 1.4. Clicking on More Properties shows added options for the form.
Settings
Form Name:
Action URL:
Method: *
~More Properties
Advanced Edic...
Cancel OK
e Enter appropriate name for the form. In the Action URL, enter the file name where
you
want the form data to be submitted. Select the method POST from the method drop
down menu, and
click on the OK button. Figure 1.5 shows the details added in the form property
dialog box.
Method: POST »
~More Properties
| Advanced Edit...
Cancel OK
8 Computer Studies : 12
In the centre of the window, you can see two panes: Site Manager and blank web
page. Site manager
is a powerful tool used to navigate within the site or between the sites. You can
close the site manager
pane by clicking on close button or press F9. The page pane shows a blank untitled
web page.
The bottom right side of the window shows Edit mode toolbar with three viewing
modes: Normal,
HTML Tags and Preview. All the three viewing modes provide editing facilities.
The Preview mode offers the page view as seen in a browser. The difference is that
in the preview
mode the scripts do not run and therefore their effects will not be seen. The links
also does not
operate in preview mode.
The Normal view is very similar to preview mode. In this mode the table outlines
are visible.
The HTML Tags view helps those who are familiar with HTML. A yellow marker is used
to indicate
the start tag for all elements. Clicking on a marker selects and highlights whole
of the element.
The left side of the page pane shows Design, Split and Source tabs. The Design tab
is used to
design the web page. The Split tab displays the HTML source of the current element.
Source tab
shows all details of the HTML code. It helps in editing the source code.
On the bottom of the window you can see the status bar. When we click on any item
in page,
its structure appears in the status bar. If you want to customize any toclbar,
right click on the respective
toolbar and click on customize toolbar option. You can then customize the toolbar
as per your choice.
To create a new file, open KompoZer. In the menu bar click File > New. A dialog box
as shown
in figure 1.3 appears with title "Create a new document or template". Select "Blank
document" option
from the options that are visible in the dialog box. At the bottom of the dialog
box you can see
a label "Create in". Select New Tab option from the drop down menu next to it. This
allows us
to create the page in a new tab. Click on the Create button.
® A blank document
_| createa XHTML document @& Strict DTD
Anew document based ona template
A blank template
Createin:; |New Tab -
Cancel Create
« You can see the form inserted with light blue colored outline in the untitled
page as shown in
figure 1.6. In normal view, the forms are shown surrounded by a dotted blue box.
All the form
elements like text box, radio button, check box and drop down box will be placed
within this
box. Press the Enter key a few times to give some space to work on the form.
e First, we will insert a label for the name field. Click on Insert > Form > Define
label.
Place the cursor in the form where you want your label to appear. Type the text
"Name" in
the label as shown in figure 1.7. To come out of the label field, click outside the
field.
S|
ie mH 4 * ul anu. 4ێ q@
ers te Pid Gimmes inal Keim dnt emaga Table Tiers rm
Body Feat =i it %) Luli cig ait = a
Bee w{eBiu
~ site Manager ‘@ honk Riad)
View: Lal filog : |
ee & ef a a ]
Name [s] Niune,
a
To insert an input text field in the form, click Insert > Form > Form Field. Figure
1.8
shows the form field properties dialog box. The drop down menu shows various input
field type
options which we had discussed earlier. Click on more properties, it shows advanced
properties
related to the field like field size, maximum length.
initial Value:
Read Only
*More Properties
Cancel
From the drop down menu select Text. Under the Field Settings heading, enter a name
in the
Field Name text box. In our case we have used name as the field name. Enter some
text in
the Initial Value field, if you want to show some text before the user actually
enters data. Here
we have left this field empty. Click on the OK button. Figure 1.9 shows the form
after text
input field is added.
10
Computer Studies : 12
« Similarly, we will add another label "E-mail" below the name label field. Add an
input text field
for E-mail, just like we did for the name field. Here enter text abc@xyz.com in the
Initial Value
textbox. This will help the user understand the format of E-mail address. Figure
1.10 shows
entitled ~ Komporer
y . = a
2.4 eo 6 bo a Ae @
bony Text my) is en: a
Varinblewidth: os||M¢ ja 4/8 } Ul/E © 4 &
i Site Manager IW funtitied) |
Views aM fides = | 7 VAbeipa |
22 fe i
Name Js]
Name |
2 E-mail fabciticyz.com
F Oeret le
+ GOM Explorer ® Design | Salit ‘ee ere Normal
abimis <bodys «farm
e Finally we will add a submit button in the form. Click Insert > Form > Form
Field, From
the drop-down menu select Submit Button. Type Submit in the both Field Name and
Field Value
text boxes, and click on the OK button. Figure 1.1] shows the look of form
properties dialog
box for submit button.
p Field Settings -
FieldName: | Submit
-More Properties
Advanced Edit...
Cancel OK
e The form at present is in the normal view. To have a preview of the form click on
Edit mode
toolbar and select Preview. Figure 1.12 shows the form in the preview mode.
_ ae SY vf - . ch G
bee i et Patan Te wirtor Lik keeps Te irre om
Body Teak, = = tL U/E & ) we =z @. |
Variable wieth > r /|\yey A\|B i USER aOo
Lz Sle Manager Siuntitied) | =
Wifes Alles: ¥ 1 7 i}
@ 6 of a = ww
Naene [=]. - a
i Name |
E-mail febogpayz con ~
Subenit
| FTP conscde "|
+ Dt Eeplorer © Design [spit [ak Soarce | Piweiew
clilink> bodys <fortiie
Thus, we have created our first form using KompoZer. You can see how KompoZer helps
you
creating forms within a short span and also relieves you from the tedious job of
writing the source
code which takes a long time. You can also see the source code of the form just
created by clicking
Bele ajiery
+ Site Manager
View: All es
# 4 7 8 a ie
Name Iz] i ne ;
FTP pongo
12 Computer Studies : 12
Let us save the file which we have created. Click File > Save. Alternatively you
can also
il
click on the save button 4 in the composition toolbar. This opens a Page Title
dialog box
as shown in figure 1.14. We can give a suitable title to the web page here. We have
given
the name "example1" to the title page. Now click on OK button.
| mi Page Title
Cancel
ox
OK
The page title will be displayed in the browser windows title bar when viewed in
the browser. In
case we have created multiple web pages we should give the name of the website as
the title page.
In this example, since we created a single web page with a form, the title page is
named as examplel.
e After clicking the OK button, a new dialog box "Save Page As" is opened which
prompts to enter
a filename and specify the location where you want to save the file as shown in
figure 1.15.
ine 3
Name: jExampletihernl
Places Name
© search example.html
<2 Recently Used farm1.htrnl
i tripti
i Desktop
Lo File System be
J 52 GB Filesystem
Lo harshil-riya
Lj 110 GB Filesyst...
7 Gocuments
a Music
df Pictures
B Videos
i Downloads
» | Size
sSa bytes Yesterday at 17:29
297 bytes Saturday 15 June 2013
Create Folder
Meordi fied
HTML Fikes: =
Cancel
Figure 1.15
13
Remember to save the file with Aire! or Ain as an extension. Click on Save button.
This will take
us back to the main window.
Note : If you are creating a website and this page is the home page that will open
when you
type the website's URL, then save the page with the name index.html.
Having learnt how to create, open, save and create a simple form in KompoZer, let
us now create
the registration form, which we had created earlier using the HTML tags. Follow the
steps given
e From the menu bar, select Inseri > Form > Define Form. In the Form Properties
dialog
box enter the details as shown in figure 1.16.
( mi Form Properties
Settings
Form Name:
Action URL:
Method:
forme
Form2.html
POST
~*More Properties
Cancel
Advanced Edit...
OK
e Press OK. A form will be displayed showing the light blue colored outline. Press
the Enter key
e To give the heading to the form, select Heading] from Format Toolbar1. In Format
Toolbar2,
select centre align icon. Enter the text "Registration Form".
e To insert the label, Click Form > Define Label. Type "First Name" in the Field
name. Next,
to insert input field for the label "First name", click Form > Form Field. Select
Text in the
Field Type menu. Figure 1.17 shows the Form Field Properties dialog box. Observe
that we
have used "firstname" as the field name. Press OK button.
Field Type
Text
Field Settings
Field Name:
initial Vaiue:
~Mare Pre
firstname
Read Only
sperties
Cancel
Advanced Edit...
OK
14
Computer Studies : 12
e Similarly, insert the label "Middle Name" and "Last Name" in the form. The form
after adding
the fields will look similar to the one shown in figure 1.18.
a_i wy aac. d@ @
Body Text mh is q|1 NE =| a == a
varoewien 3 Irele xl( a) UE Ra
fics Site Manager B(untitied) | a
View: “All files 2 [ tide I
ie a eh wi ae 7
Name a
7 4 Registration Form
First Name |
Middle Name |
Last Name |
z
hk
FTP consol
bene fualarer ® Design [EE spt |e source | Howmal
e For creating a radio button, click Form > Form Field and select field type as
Radio Button
from the drop down menu as shown in figure 1.19.
Field Type
'
Radio Button
Field Settings
Group Name: | gender
~More Properties
Advanced Edit...
Cancel OK
Type a name in the Group name box (note that the name should not contain spaces).
Here we
have entered Group Name as "gender". Similarly in the Field Value text box type
“male”. If we
want the male option of the radio button selected when the form is loaded then,
check the box
in front of the text “Initially Selected" and click OK button.
e Insert a label with title "Male" near the radio button created.
e Swunuilarly create another radio button named "Female". Remember, when we create
the radio
buttons within a group, the group name must be the same for all the possible
answers. Hence
enter the Group Name as "gender". In the Field Value text box type "female". Click
OK button.
e Insert a label "Female" near the radio button created. The form after inserting
the radio buttons
and their labels will look as shown in figure 1.20.
® Now we need to add "Hobby" field. As a person can have more than one hobby, hence
multiple
selections of hobbies are possible. Thus we need to create check box for the hobby
field. Create
a label for hobby.
e Now, click Form > Form Field and from the drop down menu select Check Box field
type.
Enter name in the Field Name box and a value in the Field Value box as shown in
figure 1.21.
Check the box in front of "Initially Selected" so as to keep the option checked
when the form
loads. Click OK button.
16 Computer Studies : 12
Highlighted by Pragati Computers, M. 99041676771.
Highlighted by Pragati Computers, M. 99041676771.
Field Type
Check Box =
Field Settings -
FieldName: | hobby
~More Properties
Advanced Edit...
Cancel OK
e Swmuilarly create two checkboxes with Field Values as "dancing" and "reading"
respectively.
Remember, to keep the Field Name same for all the options of checkbox.
e Insert the labels "Dancing" and "Reading" near the checkboxes created. The form
after inserting
checkboxes and their labels will look as shown in figure 1.22.
e Next, we need to the "Address" field. As the user enters a large text in the
address field,
we will keep the field type as textarea. First, create a label named "Address".
Now, click
Form > Text Area. This will open a Text Area Properties dialog box as shown in
figure 1.23.
(MTéxt'Area Properties.
Settings
Columns: 70
Fewer Properties
Initial Text:
Advanced Edit..
Cancel OK
Enter the Field Name. Select the rows and the columns required for the textarea.
Here we have
kept the rows as 5 and columns as 70. In the Initial Text field enter a suitable
text which will
be displayed when the form loads. Click OK button.
e Next, we will insert the "City" field. Add a label for the city field. The user
will be asked to
select the city from the drop down menu. So we need to create the city field using
selection
list option. Click Form ~ Selection List. This will open a Selection List
Properties dialog
box as shown in figure 1.24.
18 Computer Studies : 12
Type the name "city" in the List Name box and press Add Option button. Next, type
"Ahmedabad"
in the Text field. Again press Add option to add the city "Baroda". Likewise, add
the city "Rajkot"
and "Surat". Remember, to select the option "Initially Selected” when adding the
Rajkot city. Click
OK button. Figure 1.25 shows the Selection List Properties dialog for the added
cities.
Figure 1.25 : Selection List Properties dialog box for various cities
e Next, we will add the "Submit" button. Click Form > Form Field. From the drop
down menu
select Submit Button. Enter text Submit in Field Name and Field Value text box
respectively.
Click OK button.
e Similarly we will add the "Reset" button. From the drop down menu select Reset
Button. Enter
text Reset in Field Name and Field Value text box respectively. Click OK button.
The final
Save the file with name "example2". Figure 1.27 shows the preview mode of the form.
“Hes uF at. Ae @
oo % * @ | Registration Form
Naren [=|
First Name =
Middle Name | ~
Lam Name
4
8 Hobhy F Singing (7 Dancing [ Reading
Ir
|
Address
City [Rajkot
‘Aircomoe |
Rese
| — ish |
Submit, | gst
Observe that the form background is white colored. If you want to give a background
color to
the form, go to Format > Page Colors and Background. This will open a dialog box as
shown
in figure 1.29.
20 Computer Studies : 12
; Page Colors
Reader's default colors (Don't set colors in page)
@ Use custom colors: }
Activelinktext: | | ee .
| Visited link text: | ml Active tink text
Background image:
=
Advanced Edit...
Cancel | OK
Select "Use custom colors" option. Click the background option and select the color
of your choice
from the Block Background Color dialog box as seen in figure 1.30. Click OK.
button. This will
lead you back to the dialog box shown in figure 1.29. Again click OK button.
Predefined colors:
i | 6
“Ee Ss ee
HE 8 ES
[nn 8 HG
First Name |
Middle Name |
Last Name | —
Address
“FFeonsale Cily | Roikor
Suemie | Reset |
" 1 -
Figure 1.31 : Form displayed in preview mode after adding background color
View the form using the browser and observe the change in the background coler.
SUMmMary
EXERCISE
iad
State the use of Input element m HTML forms. Wnite about the different attributes
of
fA - &
input tag.
Computer Studies : 12
()
(2)
(3)
(@)
(3)
(6)
(7)
(8)
(9)
the user.
(a) Textarea (b) Form (c) Select and Option (d) Input
Which of the following is the tag used to implement form element ?
Which of the following attribute of form is used to specify where to send the form
data
when the form is submitted ?
Which of the following attribute of form specifies the HTTP method to be used when
sending the data ?
Which of the following attribute of the input element specifies the field that is
to be created
in the form ?
(a) Textarea (b) Input (c) Select and Option (d) Form
(11) Which of the following clement is used to create a drop down list or menu in a
form ?
(13) Which of the following is a free open source web development IDE ?
LABORATORY EXERCISE
2. Create a feedback form for the guests who visit your school.
3. You had gone for a vacation with your parents; the tour operator has asked you
to give
reviews of your trip. Create a form for the same.
e
24 Computer Studies : 12