Section 2 - Basics Section 4 - Advanced Forms How forms are sent Input field Buttons Input types Fieldset For more help... You try it Advanced Tables Frames Style Sheets Image Maps Section 5 - Publishing Section 6 - Extras Appendices |
Select your options: The final cool thing you are going to learn that could qualify as an input field is the <select> tag. This tag also needs an "end select" </select> tag. This tag is used for the creation of drop-down lists. Look at this one: You will actually use two kinds of tags to make a list like this. The whole list is contained between the <select> tags, but a different tag goes with every item on the list. That tag is <option> and there is no </option> tag.
Name This is a very basic list, but there are things you need to do to it to make it functional. First of all, the list really needs a name. The list above may be called "birth month" or whatever you'd like. Let's look at the second, shorter list. I'd name this list "pets" because it's descriptive. The name goes in the <select> tag.
Multiple If you want the user to be able to select several items, you can use the command MULTIPLE within the <select> tag. Multiple items can be selected by holding down the shift or control key while clicking the mouse. It might be easier using the "checkbox" command instead.
Size You can specify the number of items you'd like displayed by listing a size/ For example, on the upper lists, you noticed that only one item was displayed at a time. Perhaps you'd like two?
That covers the main modifications for the "select" tag. There are also modifications for the "option" tag. Value It's VERY important that you put a value in the option tag or you won't know what the clicked on! The value may be the same thing as the word they see, or you can add your own value. Check this out:
Selected You can pre-select one or more items on a list, and the items don't have to be at the top.
Blank? You might want to have a blank at the top of your list as your default. This allows the user to have nothing selected in a list. To do this, simply make a blank option.
Lots of information, but it will be useful to you when you're making a form. Here's a list example with these elements put together:
|