Full-house, Go-Fish, and Blackjack – some of my favorite games to play when I’m with friends. Alright, maybe that’s not true, but they’re definitely a way to pass the time. The words “deck” and “card” are synonymous to playing cards. However, they are also the terms used when developing WAP-enabled websites using WML. In this tutorial, I’ll give a breakdown on just what WAP and WML are and how they can be used. We’ll also run through creating a simple WAP-enabled site making use of multiple cards in a deck. There will be ample code to get you started on developing your own WAP-enabled site, whether for fun or for business.
WML: An Introduction - Would You Like My Special Offer (Page 4 of 6 )
In this next example, I’ll show you how WMLScript can further enhance the interaction between your WAP site and the end-user. We’ll first start by building the form interface that will be presented to the user:
You chose $result accept the "Special Offer". Thank you!<br />
</p>
<p>
An email has been sent to confirm your $email.
</p>
</card>
</wml>
We’ve created two cards in our deck. The first, Special Offer, presents a form to the user in which they can enter their name, followed by a submit button. This is how the form looks to the user:
When the submit button is pressed, our form calls the page indicated in our <go> tag; in this case, example02.wmls#prompt_user(), which calls the prompt_user() function we’re now going to create:
extern
function prompt_user(){</p> <p align="left"> </p> <p align="left"> var user_name = WMLBrowser.getVar("userName");
var prompt = "Would you like to accept our "Special Offer", " + user_name + "?";
var yes = "Yes";
var no = "No";
var result = Dialogs.confirm(prompt,yes,no);</p> <p align="left"> </p> <p align="left"> if (result == true){
WMLBrowser.go("mailto:frank@developershed.com?from=Special Offer Administrator&subject=Special Offer&body=You accepted the special offer. Thank you!");
WMLBrowser.go("mailto:frank@developershed.com?from=Special Offer Administrator&subject=Special Offer&body=Thank you for considering our offer. Stay tuned for new offers!");
WMLBrowser.go("example.wml#result");
}
}
The prompt_user() function is fairly straightforward. We first make use of the extern keyword to indicate that the function is available to an outside file, in our case example02.wml. We then create our local variables, which will be used to create the user prompt. Our result variable will hold the returned value sent from the user confirmation (a Boolean value).
We then test to see if our result is true. We then test to see if result is true or false. Next, we set the value to our variables (result and email) in the “result” card (see example02.wml), which will be displayed to the user after sending a confirmation email indicating the users selection (yes or no).
The final output displayed to the user is shown below: