19. WML Input Fields
Input fields are used to obtain alphanumeric data from users. The <input/> tag is used to create input fields. Let's first take a look at the following WML example. Then we will mention about some of the commonly used attributes of the <input> element.
<?xml
version="1.0"?>
<!DOCTYPE wml PUBLIC
"-//WAPFORUM//DTD WML 1.3//EN"
"http://www.wapforum.org/DTD/wml13.dtd">
<wml>
<card
id="card1" title="WML Input
Fields">
<p>
Hello,
welcome to our WML tutorial.<br/>
What's
your name?
<input
name="myname" maxlength="16"/>
</p>
</card>
</wml>
Like a selection list, an input field is associated with a variable, which stores the data entered by the user. The variable name is specified with the name attribute of the <input> element. In the above WML example, a variable myname is associated with the input field. If you enter Tom in the input field, the variable myname will contain the value Tom. Further details about variables will be discussed in the section "WML Variables" of this tutorial.
The maxlength attribute of the <input> element limits the number of characters that a user can enter in an input field. In the above WML example, a user can enter at most 16 characters in the input field.
The following screenshots show the result of the above WML example in some mobile phone browsers:
|
|
|
In the above WML example, we have not set a default value to the input field. So, as you can see in the screenshots, the input field is empty at the beginning. If you want to set a default value to the input field, you need to specify the value attribute in the <input> element. For example, if we change the following line:
<input name="myname" maxlength="16"/>
to:
<input name="name" maxlength="16" value="Jack"/>
Then the input field will contain the word "Jack" by default.
Previous Page | Page 35 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