JavaScript is not enabled in your browser. These examples will not work without JavaScript.

Forms: Select Menu

We use selected in the HTML to pre-select one item in a menu like this one. If no line has that designation, the initial choice will be the top item. If you want a blank item to show, you must create a blank (empty) option.

The menu scrolls to reveal all 50 U.S. states. The number of options that are visible is set in the HTML with the size attribute.

Choose any state from the menu. The value (which is that state's abbreviation) will be written into the text field at right. Click Submit to see both the state name and the abbreviation written into the document.

Note that the Reset button resets all form elements, but it does not reload the page.


Return to the index.