Chapter 5-1
Chapter 5-1
Name the attributes which are used with the <INPUT> tag.
Answer
The attributes which are used with the <INPUT> tag are:
1. Type
2. Name
3. Value
4. Size
5. Maxlength
Question 2
Answer
The <SELECT> tag along with the <OPTION> tag is used to create a drop-down list on a
form area.
Question 3
Which attribute of <INPUT> tag specifies what type of form control will be added to the
form area?
Answer
The 'type' attribute of <INPUT> tag determines the type of form control that will be added
to the form area
Question 4
Answer
The <TEXTAREA> tag adds a multi-line text box on the form area.
Question 5
Answer
1. Form Header
2. Input Fields
3. Action Buttons
Question 6
Answer
The purpose of a password field is to securely input and hide confidential information like
passwords or PINs by displaying dots or asterisks instead of the actual data.
Question 7
Answer
A scroll bar added to a combo box indicates that there are more elements in the list and
helps to navigate through this longer list of options.
Question 8
How can you select multiple options from the items displayed in a list?
Answer
We can select multiple options from the items displayed in a list by using the entity
"multiple". The Ctrl or Shift keys are used to select more than one element from the list.
Question 1
What do you understand by the Method attribute? Differentiate between the Get method
and the Post method.
Answer
The Method attribute specifies that the form information should be posted to the URL given
in the action attribute. Possible values are GET and POST.
Differences between the Get method and the Post method are:
S.
Get Method Post Method
No.
Less data can be sent compared to More data can be sent compared to
2.
Post method. Get method.
Question 2
Answer
1. Text Box — A text box allows a user to enter alphanumeric data that is a
combination of characters and numbers. It creates a single line text box. We can add
a text box to the form in the following way:
Syntax: <INPUT Type= "Text">
2. Checkbox — A checkbox is like a toggle switch which helps the user to select or
deselect one or more items. We have to type the label next to the checkbox.
Syntax: <INPUT Type = "Checkbox" Name = "Hobbies" Value = "Reading">
The below example shows the usage of textbox and checkbox in a form:
<HTML>
<BODY>
<FORM>
<P>
NAME :
<INPUT TYPE = "TEXT">
</P>
<P>
CHOOSE YOUR QUALIFICATION : <BR>
<INPUT TYPE = "CHECKBOX" NAME = "C1" VALUE = "GRADUATE">
GRADUATE <BR>
<INPUT TYPE = "CHECKBOX" NAME = "C2" VALUE = "POSTGRADUATE" >
POST GRADUATE
</P>
</FORM>
</BODY>
</HTML>
Question 3
Differentiate between:
Answer
S.
Radio Button Checkbox
No.
Radio buttons are used when we want Checkboxes are used when we
1. users to select only one option from a want users to select multiple
set of choices. options from a list.
S.
Submit Button Reset Button
No.
Answer
1. Educational sites — They are used for collecting names, addresses, telephone
numbers, e-mail addresses, and other information of students which is required by
the websites to register them for an online course.
2. Online shopping — They are used for gathering information for the purchase of an
item. For example, if we want to purchase a book or any other item over the
Internet, we would be required to fill in our name, mailing address, mode of
payment that we wish to opt for, and so on.
3. Online Feedback Forms — They are used for collecting feedback about a website.
Most websites that offer a service encourage the users to send their feedback. Apart
from building customer relations, it is a source of information for modifications or
improvements.
4. Providing Interface for a Chat Session — Users are required to fill out a form if
they want to participate in a chat session or a discussion group.
Question 5
ii. Value
iii. Size
Answer
i. Type — This attribute specifies what kind of form control will be added to the form. The
default type for an input element is "Text". Type attribute can take different values like
"Text", "Checkbox", "Radio" or "Password".
Question 6
Describe the Cols attribute and Rows attribute of the <TEXTAREA> tag.
Answer
Rows attribute of the <TEXTAREA> tag defines the height of the textarea and Cols
attribute of the <TEXTAREA> tag defines the width of the text area.
Consider the following example,
<HTML>
<HEAD>
<TITLE>Using text area</TITLE>
</HEAD>
<BODY>
<FORM>
Remarks : <TEXTAREA ROWS = "6" COLS = "50" NAME = "REMARKS">
Enter your remarks here. </TEXTAREA>
</FORM>
</BODY>
</HTML>
Application Based Questions
Question 1
Shagun wants to customize the width and height of the textarea in her form. How can she
do it?
Answer
Shagun can use the Rows and Cols attribute of the <TEXTAREA> tag to customize the
width and height of the textarea in her form. Rows attribute defines the height of the
textarea, and Cols attribute defines the width of the text area. Example code for
customizing the width and height of the textarea is:
<TEXTAREA ROWS = "6" COLS = "50" NAME = "REMARKS">
Enter your remarks here.
</TEXTAREA>
Question 2
Answer
Question 3
In the examination, Suparna has been asked to write the code for placing a drop-down list
in the form area. She is also asked to indicate any one of the menu items as preselected.
Help her in solving the problem.
Answer
Suparna can use the selected attribute with the <OPTION> tag to indicate that one of the
menu items is preselected.
Consider the following example in which the user has to select his destination. Here, the
option "Chandigarh" is pre-selected.
<HTML>
<HEAD>
<TITLE>Drop-down Example</TITLE>
</HEAD>
<BODY>
<FORM>
<P> Select your destination: </P>
<SELECT Name = "Cities">
<OPTION Selected> Chandigarh</OPTION>
<OPTION> Kolkata </OPTION>
<OPTION> Bhopal </OPTION>
<OPTION> Lucknow </OPTION>
<OPTION> Patna </OPTION>
<OPTION> Shimla </OPTION>
<OPTION> Delhi </OPTION>
<OPTION> Mumbai </OPTION>
<OPTION> Chennai </OPTION>
</SELECT>
</FORM>
</BODY>
</HTML>