20. WML Variables
A major difference between WML and HTML is that WML has build-in support of variables. You can assign a value to a variable or output the value of a variable in WML without involving any scripting languages. To use variables in HTML, a client-side scripting language (e.g. JavaScript and VBScript) is required.
20.1. Setting Variable Values in WML
In WML, variables do not have to be declared explicitly. You can choose a variable name you like and assign a value to it directly. If you read a variable without assigning a value to it earlier, you will obtain an empty string.
Variable names in WML are case-sensitive. The first character of a variable name must be a letter or an underscore. The rest of the characters can be letters, numbers or underscores. Other characters, such as punctuations, are not permitted.
All variables are stored as string. They have a global scope, which means once you have set the value of a variable, you can read it in any cards and decks.
You can set the value of a variable in the following ways:
Using the <setvar/> tag
Using data collection tags <select> and <input/>
Using the setVar() function of WMLScript's WMLBrowser standard library
Previous Page | Page 39 of 50 | Next Page |
- 1. WML (Wireless Markup Language) Introduction
- 2. WML Deck and Card
- 3. WML Document Structure
- 4. WML Generic Metadata: <meta>
- 5. Comments in WML
- 6. Line Breaking in WML
- 7. Font Size and Style in WML
- 8. WML Preformatted Text: <pre>
- 9. WML Images
- 10. WML Tables
- 11. WML Anchor Links
- 12. Programming Softkeys of Mobile Phones and the <do> Element
- 13. WML Template and Menu
- 14. WML Events and the <onevent> Tag
- 15. Timer and the ontimer Event
- 16. WML Event: onenterbackward
- 17. WML Event: onenterforward
- 18. WML Selection Lists and the onpick Event
- 19. WML Input Fields
- 20. WML Variables
- 21. Submitting Form Data to the Server in WML
- 22. Clearing a Saved Form in WML