SoFunction
Updated on 2025-04-07

WML Learning Six Events

event
WML events are basically divided into two categories. One is the keyboard (including soft and hard buttons) input events, which are handled with the <do> tag, and the other is the events inside the related page, which are handled with the <onevent> tag.
The syntax of <do> is as follows: <do type="type" label="label" name="name" optional="false|true">task</do>, task is the four tasks mentioned before. In the <do> attribute, type is required, and others are optional.
*label attribute specifies the display text of the soft button on the screen. Currently, the type attribute is delete, help, and prev.
*name attribute, give a name for <do>, and the <do> in the same CARD cannot be duplicated. If the CARD level <do> and the DECK level <do> are the same name, the DECK level <do> is overwritten.
*optional attribute, specify whether the phone can ignore this event, the default value is false.
*type attribute, specify the triggered event, as follows;
Type value trigger reason
accept  Calling ACCEPT button mechanism
delete  Calling the DELETE button mechanism
help  Calling the HELP button mechanism
options Calling the selection button mechanism
prev call PREV button mechanism
reset  The RESET mechanism when calling the clear and reset mobile phone status (not currently supported)
unknown    Calling the unknown mechanism is equal to type="" (not currently supported)
vnd.co-type calls manufacturer-specific mechanisms (not currently supported)
X-*, x-* for future use (not retained) (not supported at present)

---------------
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "/DTD/wml_1.">
<wml>
<head>
<meta http-equiv="Cache-Control" content="max-age=0"/>
</head>
<card  ordered="false">
<do type="accept" label="InputName" name="do1">
<go href="#card01"/>
</do>
<p>
NAME:<input name="userName" title="User Name" type="text" format="*M" emptyok="false" maxlength="12"/>
</p>
</card>
<card >
<p>
You name is $(userName:noesc).
</p>
</card>
</wml>
The syntax of <onevent> is as follows, <onevent type="type">task</onevent>, and the value of the required attribute type is as follows:
Type value: If the user performs the following operations, the task will be executed.
onpick When the user selects or does not select a <option> item.
onenterforward When the user reaches a CARD using the <go> task.
onenterbackward When the user uses the <prev> task to return to the previous CARD, or when the BACK button is pressed.
ontimer When <timer> expires.

---------------
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "/DTD/wml_1.">
<wml>
<head>
<meta http-equiv="Cache-Control" content="max-age=0"/>
</head>
<card  ordered="false">
<p>
Please select a city...
<select title="Cities List" name="city">
<option title="Beijing" value="Beijing">
<onevent type="onpick">
<go href="#card01"/>
</onevent>Beijing</option>
<option title="Shanghai" value="Shanghai" onpick="#card01">Shanghai</option>
<option title="Hongkong" value="Hongkong" onpick="#card01">Hongkong</option>
</select>
& lt;/p>
</card>
<card >
<p>
You are Living in $(city:noesc)
</p>
</card>
</wml>
<timer/> can be used to automatically execute a task after a period of time when the user does not perform any operations. Any tasks and user operations that activate the CARD page will start <timer/>, and when the task is in progress, <timer/> will stop. Each CARD can only have one <timer/>, and one <timer/> can only trigger one task. The syntax is as follows: <timer name="variable" value="value"/>, where name is an optional property, specified as a variable name. When the CARD is exited, the variable stores the value of the timer at this time. When the timer timed out, the mobile phone sets the variable to 0; value is a required property, which is used to set the timer's timing value, with the minimum unit being 0.1 seconds.

---------------
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "/DTD/wml_1.">
<wml>
<head>
<meta http-equiv="Cache-Control" content="max-age=0"/>
</head>
<card  ontimer="#card2">
<timer name="time1" value="50"/>
<p align="center">
After 5s, goto card2
</p>
</card>
<card >
<onevent type="ontimer">
<go href="#card1"/>
</onevent>
<timer name="time2" value="50"/>
<p align="center">
Here is card2!
</p>
</card>
</wml>
Let me mention again, <onevent> <timer> <do> three must be written in the above order.
In addition, <template> can be added at the DECK level to bundle events on the DECK level. The syntax is as follows:
 <template onenterforward="url" onenterbackward="url" ontimer="url">
<do> or <onevent>
 </template>

---------------
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "/DTD/wml_1.">
<wml>
<head>
<meta http-equiv="Cache-Control" content="max-age=0"/>
</head>
<template>
<do type="accept" label="deckPress" name="do1">
<go href="#card01"/>
</do>
</template>
<card  ordered="false">
<do type="accept" label="cardPress" name="do1">
<go href="#card02"/>
</do>
<p>
Press ACCEPT...
</p>
</card>
<card >
<p>
Here is card01
</p>
</card>
<card >
<p>
Here is card02
</p>
</card>
</wml>