O'Reilly logo

Learning WML, and WMLScript by Martin Frost

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The <option> Element

While on the subject of the <select> element, it’s time for a closer look at the <option> element that is so vital to it. You’ve already seen the two most common ways to use this element (with or without a value), but it’s also possible to bind a task to an option, so that the task is performed when the user selects the option (or deselects it, for a multiple-selection list).

This task is bound to the onpick event. It can be bound either with a conventional <onevent> binding, or for simple <go> tasks it can be specified with the onpick attribute on the <option> tag itself.

Attributes of the <option> Element

value (optional variable string)

Gives a value to this <option>, which is stored in the name variable of the <select>, as detailed earlier.

title (optional variable string)

Gives a title to this <option>, which some browsers may use to display the option, but some may ignore.

onpick (optional variable URL)

Provides a shorthand method of binding to the onpick event, for the common case where the task is a simple go. Because this task is reduced to just the URL, it cannot contain any <setvar> or <postfield> elements, and its method is limited to GET. In complicated cases, put an <onevent type="onpick"> element of type onpick inside the <option> element.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required