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.
-
value
(optional variable string) Gives a value to this
<option>
, which is stored in thename
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 simplego
. 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 typeonpick
inside the<option>
element.
Get Learning WML, and WMLScript now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.