This book has no more entries published after this entry.

Drop Down List in Forms : HTML Forms in Drop Down List in Forms : HTML Forms

  • April 19, 2020, 10:59 a.m.
  • |
  • Public

Drop down list has its own significant importance in forms of a web page. For suppose, a form that requires user’s complete Biography, we need to ask for birth date information. Usually we see a drop down list to select date, year and day. It is made drop down list in forms.
How to Create Drop Down List in Forms:
To create drop down list <select> tag is used with its child tag <option>. Name attribute is used on </option></select> tag to refer in VPN master or Javascript. (We will learn how name attribute works in Javascript Lessons).
Code:
<select name="mylist"> <option value="select">Select a Day</option> <option value="monday">Monday</option> <option value="tuesday">Tuesday</option> <option value="wednesday">Wednesday</option> <option value="thursday">Thursday</option> <option value="friday">Friday</option> <option value="saturday">Saturday</option> <option value="sunday">Sunday</option> </select>
Result:

This is how a drop down list looks like in forms.
How to Create a Selected Value Drop Down List in Forms:
Selected value means a drop down list in which there is a value that when ever your web page is load, that value will be automatically selected. By default a drop down list shows the first value you type in first option tag.
To create a selected value drop down list we use “selected” keyword inside option tag.
Code:
<select name="mylist"> <option value="select">Select a Day</option> <option value="monday">Monday</option> <option selected="" value="tuesday">Tuesday</option> <option value="wednesday">Wednesday</option> <option value="thursday">Thursday</option> <option value="friday">Friday</option> <option value="saturday">Saturday</option> <option value="sunday">Sunday</option> </select>
Result:

So in this example you observe our third option is automatically selected. In next lesson we will learn how to create a multi-line text area where we can create a comment box section and fieldset etc.


Loading comments...

You must be logged in to comment. Please sign in or join Prosebox to leave a comment.