WML - onpick Attribute



The onpick attribute is a great shortcut if you are using a select menu. Instead of writing a lot of code that allows the user to go to another card if an option is selected, you can simply place the destination into the onpick attribute. Here is a code fragment without the onpick attribute:

Following is the example showing usage of onpick attribute alongwith <option> element.

<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.2//EN"
"http://www.wapforum.org/DTD/wml12.dtd">

<wml>

<card id="tutorials" title="Main Menu">
<p>
  Select a tutorial :
  <select title="tutorials" name="selection_list">
    <option onpick="#xhtml">XHTML Tutorial</option>
    <option onpick="#wap">WAP Tutorial</option>
  </select>
</p>
</card>
<card id="xhtml" title="XHTML Tutorial">
<p>
Go through our XHTML tutorial
</p>
</card>
<card id="wap" title="WAP Tutorial">
<p>
Go through our WAP tutorial
</p>
</card>
</wml>

When you load this program, it shows you following screen:

WAP Exampple16

Now, highlight the dropdown box and select it. It will give you two options as follows:

When you load this program, it shows you the following screen:

WAP Exampple17

Now, assume you select WAP Tutorial from the list, then it will display the following screen:

WAP Exampple18
wml_events.htm
Advertisements