Calling a WMLScript function and passing parameters or setting variables requires the following information in the WML file:
The name and URL location of the WMLScript file.
The name of the desired external function, separated from the WMLScript file name by a hash mark (#).
The name and value of any parameters passed or variables set from the WML file to the WMLScript function.
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.