logo

Very Short Question and Answers - Drop-down List and Combo Box


Q 1.
What is the main purpose of a drop-down list in a web form?

Ans:

The main purpose of a drop-down list is to allow users to select one (or sometimes multiple) options from a compact list, saving space on the web page.

Q 2.
Which HTML tags are used to create a drop-down list?

Ans:

The <select> tag creates the drop-down list, and <option> tags are used for each choice inside the list.

Q 3.
Write the syntax for a basic drop-down menu with three cities: Delhi, Mumbai, and Chennai.

Ans:

<select name="city">
  <option value="delhi">Delhi</option>
  <option value="mumbai">Mumbai</option>
  <option value="chennai">Chennai</option>
</select>
Q 4.
What is the use of the 'name' attribute in the <select> tag?

Ans:

The 'name' attribute assigns a name to the drop-down, and this name is sent to the server when the form is submitted.

Q 5.
Explain the purpose of the 'id' attribute in the <select> tag.

Ans:

The 'id' attribute gives a unique identifier to the drop-down, which can be used in CSS for styling or JavaScript for scripting.

Q 6.
How can you allow users to select more than one option from a <select> list?

Ans:

By adding the 'multiple' attribute to the <select> tag, users can select more than one option. For example: <select multiple>.

Q 7.
What happens if you set the 'size' attribute to a value greater than 1 in the <select> tag?

Ans:

The drop-down will display as a list box, showing the number of options based on the value of 'size'. For example, size="3" shows three items at once.

Q 8.
What is the function of the 'value' attribute in the <option> tag?

Ans:

The 'value' attribute sets the data that is sent to the server if that option is selected.

Q 9.
How do you make an option selected by default in a drop-down list?

Ans:

By adding the 'selected' attribute to the <option> tag. For example:

<option value="mumbai" selected>Mumbai</option>
Q 10.
What does the 'disabled' attribute do when used in a <select> or <option> tag?

Ans:

The 'disabled' attribute makes the entire drop-down (for <select>) or a specific option (for <option>) unselectable by the user.

Q 11.
Give an example of a drop-down list that allows users to pick multiple favourite subjects.

Ans:

<select name="subjects" multiple size="4">
  <option value="maths">Mathematics</option>
  <option value="science">Science</option>
  <option value="english">English</option>
  <option value="sst">Social Studies</option>
</select>
Q 12.
What is a combo box in web forms, according to Class 10 CBSE syllabus?

Ans:

A combo box is a form element that allows users to either type a value or select a value from a predefined list; in basic HTML, it can be created using the <input> element with a <datalist>.

Q 13.
How do you create a combo box using HTML5 tags?

Ans:

By using <input list="id"> and a <datalist> with corresponding <option> elements. For example:

<input list="subjects" name="subject" />
<datalist id="subjects">
  <option value="Mathematics"></option>
  ...
</datalist>
Q 14.
What is the use of the <datalist> element in HTML?

Ans:

The <datalist> element provides a list of predefined options to an <input> element, allowing users to either type or select a value.

Q 15.
Write the syntax for a combo box that allows users to select or type their course name.

Ans:

<input list="courses" id="course" name="course" />
<datalist id="courses">
  <option value="Computer Applications"></option>
  <option value="Artificial Intelligence"></option>
  ...
</datalist>
Q 16.
Can users select multiple options in a combo box created using <input> and <datalist>?

Ans:

No, users can select only one option or type one value in a combo box using <input> and <datalist>.

Q 17.
State one difference between a drop-down list and a combo box.

Ans:

A drop-down list only allows selection from given options, while a combo box (using <datalist>) allows users to type their own value or pick from suggestions.

Q 18.
Which attribute of <datalist> connects it to an <input> field?

Ans:

The 'id' attribute of the <datalist> should match the 'list' attribute value of the <input> field.

Q 19.
When should you use a drop-down list instead of a combo box?

Ans:

When you want users to choose from a set of fixed, predefined options and do not want them to enter their own values.

Q 20.
Mention two key attributes of the <option> tag and their purposes.

Ans:

    1. value – the data sent to the server upon selection;
    1. selected – makes the option selected by default when the form loads.