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"?>


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

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