Home / code / html

The select element.

This gives a drop-down menu or a choice-list.
As always you have to give it a name.
<SELECT NAME="thename"></SELECT>

The attribute size:
<SELECT NAME="thename" SIZE="4"></SELECT>

This is the amount of choices that has to be shown. There can be more choices but only 4 are shown.
If you leave the SIZE out, you get a drop-down menu.

Choice list Drop-down menu

If you want that people should be able to select more then 1 option, you should add multiple.
<SELECT NAME="thename" SIZE="4" MULTIPLE></SELECT>

Now how the add the options?
For each option you add <OPTION>, to end the option you can add </OPTION> but this is not necessary.
So a full list looks like this:

<select name="thename" size="4">
   <option VALUE="option1">First option</option>
   <option VALUE="option2">Second option</option>
   <option VALUE="option3">third option</option>
   <option VALUE="option4">Fourth option</option>
   <option VALUE="option5">Fifth option</option>
   <option VALUE="option6">Sixth option</option>
</select>
A value is what has to be send through.

The attribute selected.
When you use this on a option, that option will be selected when the page opens.
<OPTION VALUE="option1" SELECTED>First option</OPTION>

 

TOP

Latest script:

 

Books: