Computer Applications
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>
Related Questions
Define the following attributes associated with the
<INPUT>tag:i. Type
ii. Value
iii. Size
Describe the Cols attribute and Rows attribute of the
<TEXTAREA>tag.Shagun wants to customize the width and height of the textarea in her form. How can she do it?
Write the HTML code to create the following form elements:
