KnowledgeBoat Logo
|

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.

HTML Advanced Features

11 Likes

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>

Answered By

9 Likes


Related Questions