WMLScript Developer's Guide

[Cover] [Previous Section] [Next Section] [Index]

Current chapter: Chapter 8 - Calling WMLScript Functions from WML
Section 45 out of 57 total sections , Section 4 out of 6 sections in this chapter


Calling a Function and Passing Parameters or Setting Variables from WML

Calling a WMLScript function and passing parameters or setting variables requires the following information in the WML file:

In addition to this information, you also need to determine the circumstances under which the WML file calls WMLScript function. A common example would be to call a WMLScript function in response to an event, such as the user selecting a menu option.

For example:

<option>Sample  
    <onevent type="onpick">  
        <go href="/scripts/sample.wmls#myfunction("../alt")">  
            <setvar name="action" value="reset"/>  
        </go>  
    </onevent>  
</option>  

The first line in this example that is relevant to this discussion is:

<go href="/scripts/sample.wmls#myfunction("../alt")">  

This line tells the UP.Browser to look for the file sample.wmls using a relative URL. If the desired WMLScript file is on a different server, use a full URL to describe its location. This line also tells the UP.Browser to find myfunction() in the file sample.wmls. Notice that the full declaration of the function must be used, including any parameters or empty parentheses [()] if there are no parameters. This example passes the string "../alt" to myfunction.

The second line in this example that is relevant to this discussion is:

<setvar name="action" value="reset"/>  

This line tells the UP.Browser to pass the variable action with a value of reset to myfunction. At this point, the WMLScript file takes the parameter and variable passed to it and acts on them.


[Cover] [Previous Section] [Next Section] [Index]


Part Number DKDS-41-002, UP.SDK Release 4.1, December 2000

Copyright © 1994-2000 Openwave Systems Inc. All rights reserved.
Please send comments and questions to sdk-doc-comments@openwave.com.