Code for Drop-down menu in Html form

Posted: June 8, 2012 by makaranddalal in HTML

Select and option tag usage:


<!DOCTYPE html>
<html>
<body>

<form action=””>
<select name=”Year”>
<option value=”1995″>1995</option>
<option value=”1994″>1994</option>
<option value=”1993″>1993</option>
<option value=”1992″>1992</option>
<option value=”1991″>1991</option>
<option value=”1990″>1990</option>
<option value=”1989″>1989</option>
</select>
</form>

</body>
</html>


Selected attribute

The drop-down menu shows the value with selected attribute on top


<!DOCTYPE html>
<html>
<body>

<form action=””>
<select name=”Ice-creams”>
<option value=”Vanilla”>Vanilla</option>
<option value=”Strawaberry”>Strawberry</option>
<option value=”Mango” selected=”selected”>Mango</option>
<option value=”Chocolate”>Chocolate</option>
</select>
</form>

</body>
</html>


In above example Mango will be displayed first in drop-down menu

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s