0% found this document useful (0 votes)
4 views

class 10 chapter 4 HTML FORMS (2)

Uploaded by

weuswebs
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

class 10 chapter 4 HTML FORMS (2)

Uploaded by

weuswebs
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

CHAPTER 4: HTML FORMS

CHAPTER 4: HTML FORMS


Exercises
OBJECTIVE TYPE QUESTIONS
MULTIPLE CHOICE QUESTIONS (MCQs)
1. Which is the default of ‘type’ attribute of <input> element?
a) Text
b) Password
c) Numerals
d) Special Characters
Ans: a) Text

ny
2. Which attribute defines the file-select field?
a) file
b) checkbox

pa
c) button
d) text
om
Ans: a) file
3. Which of the following is not used with password attribute?
a) name
C

b) size
c) maxlength
d) min
&

Ans: d) min
d

4. Which element is used to create multiline text input?


a) text
n

b) textarea
ha

c) submit
d) radio button
Ans: b) textarea
C

5. Which attribute is not used for the radio type?


a) name
S.

b) value
c) checked
d) selected
Ans: d) selected
6. Which attribute is used with <select> element?
a) multiple
b) selected
c) name
d) value
Ans: a) multiple
THEORETICAL QUESTIONS
1. Mention the purpose of using Web Forms.
Ans: A web form is a medium that allows your visitors to get in contact with you and to send
information, such as an order, a catalogue request, or even a query, which is passed on to your
database.

2. What are Web Forms?


Ans: A web form (or HTML form) is a place where users enter data or personal information that is
then sent to a server for processing.

3. Differentiate between
1. Get & Post methods of Form tag
2. Text Field and Text Area Controls
3. Radio buttons and Check box

ny
Ans:
1. The GET and POST method are used for sending the data to the server, and the main

pa
difference between them is that GET method append the data to the URI defined in the
form’s action attribute. Conversely, POST method attaches data to the requested body.
2. The major difference between a text area and a text field is that a text field only has one line
om
whereas a text area is usually has multiple lines.
3. Checkboxes allow the user to choose items from a fixed number of alternatives, while radio
buttons allow the user to choose exactly one item from a list of several predefined
C

alternatives.

4. Mention all attributes of following controls used in forms.


&

Ans:
1. Text = type, name, value, size, maxlength
d

2. Checkbox = type, name, value, checked


n

3. Radio = type, name, value


4. Password = type, name, value, size, maxlength
ha

5. Submit = type, name, value


6. Reset = type, name, value
C

5. Which method is used to send form data as URL variables?


Ans: <form method=”POST”>
S.

6. How can you select 3rd option by default in a list used in HTML Forms?
Ans: The default value of the select element can be set by using the 'selected' attribute on the
required option. This is a Boolean attribute. The option that is having the 'selected' attribute will be
displayed by default on the dropdown list.

APPLICATION BASED QUESTIONS


1. Write an HTML code for creating a form, which accepts the birth date from the user in a
textbox and displays the day of the week in a message box on the click of a button.
Ans:
<form onsubmit = 'myFunction()'>
<label for="start">Enter Your Birth Date (YYYY-MM-DD):</label>
<input type="text" id="bday" name="bday" value="2000-01-01" id="bday">
<BR><BR>
<input type="submit" value="Show Week Day Name">
<script type= 'text/javascript'>
function myFunction()
{
var a = new Date(document.getElementById("bday").value)
var days = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];
var DayName=days[a.getDay()]
document.write("Week Day Name:" + DayName)
}
</script>
</form>

ny
Output

pa
om
C
&

2. Write code to create the following HTML Form to accept User’s Information as part of a
d

Magazine Survey:
n
ha
C
S.

Note: Address accepts multiline text.


Ans:
<form>
<B>User Survey</B> <br>
<label for="Name">Name: </label> <br>
<input type="text" id="Name" name="Name"/> <br>
<label for="Address">Address: </label>
<input type="text" id="lastname" name="lastname"/> <br>
<input type="radio" id="gender" name="gender" value="male"/>Male
<input type="radio" id="gender" name="gender" value="female"/>Female <br/>
You came to know about your magazine from:
<input type="checkbox" id="Friend" name="Friend" value="Friend"/>
<label for="Friend">Friend</label>
<input type="checkbox" id="Newspaper" name="Newspaper" value="Newspaper"/>
<label for="Newspaper">Newspaper</label>
<input type="checkbox" id="TV/Radio" name="TV/Radio" value="TV/Radio"/>
<label for="TV/Radio">TV/Radio</label>
<input type="checkbox" id="Others" name="Others" value="Others"/>
<label for="Others">Others</label>
</form>

3. What is FORM tag? Explain with example.

ny
Ans: An HTML form is a section of a document which contains controls such as text fields, password
fields, checkboxes, radio buttons, submit button, menus, etc.
An HTML form facilitates the user to enter data that is to be sent to the server for processing, such

pa
as name, e-mail address, password, phone number, etc.
om
4. Write a program to declare 2 radio buttons (Male, Female) and one check box (hobbies) in the
HTML form.
Ans: <form>
<label for="gender">Gender: </label>
C

<input type="radio" id="gender" name="gender" value="male"/>Male


<input type="radio" id="gender" name="gender" value="female"/>Female<br/>
&

<input type="checkbox" id="hobby" name="hobby" value="hobby"/>


</form>
d

5. Write code to create the following HTML Form:


n
ha
C
S.

Ans:
<body>
<form>
Please input your name<br>
<input type="text" name="username">
<input type="submit" value="submit">
</form>

</body>

You might also like