tailieunhanh - Webmaster's Guide to the Wireless Internet part 19

Webmaster's Guide to the Wireless Internet part 19. The Webmaster’s Guide to the Wireless Internet provides the Wireless Webmaster with all of the tools necessary to build the next generation Internet. Packed with the essential information they need to design, develop, and secure robust, e-commerce enabled wireless Web sites. This book is written for advanced Webmasters who are experienced with conventional Web site design and are now faced with the challenge of creating sites that fit on the display of a Web enabled phone or PDA | 152 Chapter 4 Enhancing Client-Side Functionality with WMLScript Figure WMLScript Program to Calculate the Factorial of a Number extern function Calculate num var result 1 for var i 1 i num i result i result result card2 Dissecting the Code In this example we want the WMLScript see Figure to calculate the factorial of a number and display the result in a card. This example illustrates several different features of the WMLScript language. Let s take a closer look at the WML deck see Figure input type text name num The user enters a number through the use of the input element. go href Calculate num The Calculate function within the file is number entered by the user num is passed to the function. card id card2 title Card 2 p num is result p card Card2 will display the result of the operation performed by the WMLScript. The value of result is set by the WMLScript function. Within the WMLScript function we have the function declaration of Calculate extern function Calculate num var result 1 Enhancing Client-Side Functionality with WMLScript Chapter 4 153 A new variable result is defined with the var keyword and set to a value of 1. for var i 1 i num i result i The for loop repeatedly executes a set of instructions. In this case it multiplies all the numbers from 1 to num. result result The result is stored into the WML variable result using the setVar function from the WMLBrowser library. Notice that a pair of double quotes encloses the WML variable result. card2 Once the result is stored card2 from the WML deck is loaded using the go function from the WMLBrowser library. Figure displays the resulting screens on the WAP Toolkit. Figure Performing Mathematical Operations Using WMLScript _Card 1 Factorial machine Enters number Option .Card 5 to 120 Using WMLScript for Input .

TỪ KHÓA LIÊN QUAN