Displaying Confirmation Messages on the Screen of Wireless Devices: confirm() Function

Preferences - Do not show ads

The confirm() function of the Dialogs standard library is used to display a confirmation message on the screen of a wireless device. Below is the syntax of confirm():


Dialogs.confirm(message, ok, cancel);


message is the message to be displayed. If the user selects the option labeled with ok, the confirm() function returns the Boolean value true; if the user selects the option labeled with cancel, it returns the Boolean value false; if any error occurs, it returns invalid.

Below shows a WML/WMLScript example that illustrates the usage of confirm():


(confirmEg1.wml)

<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.3//EN" "http://www.wapforum.org/DTD/wml13.dtd">

<wml>
  <card id="cell_phone_card" title="Buy Cell Phone">
    <p>
      Which cell phone do you want to buy?<br/>
      <select name="cell_phone_model">
        <option value="a">Model A</option>
        <option value="b">Model B</option>
        <option value="c">Model C</option>
      </select><br/><br/>

      <a href="confirmEg1.wmls#confirmBuy()">Continue</a>
    </p>
  </card>
</wml>


(confirmEg1.wmls)

extern function confirmBuy()
{
  var cell_phone = WMLBrowser.getVar("cell_phone_model");
  var message = "The price of the cell phone you have chosen is $";
  if ("a"==cell_phone)
    message += "200";
  else if ("b"==cell_phone)
    message += "300";
  else if ("c"==cell_phone)
    message += "250";
  message += ". Do you want to proceed to checkout now?";

  var toCheckout = Dialogs.confirm(message, "Yes", "No");
  if (true==toCheckout)
    WMLBrowser.go("checkout.wml");
}


Open the WML document of the example in a mobile phone browser:






Sony Ericsson T68i


Nokia Mobile Browser 4.0


If you choose any of the cell phone models and click the "Continue" link, the mobile phone browser will display a confirmation message that is generated by the confirm() function:






Sony Ericsson T68i


Nokia Mobile Browser 4.0


If you press the "Yes" button of the Sony Ericsson T68i emulator or the "Yes" softkey of the Nokia Mobile Browser, the mobile phone browser will load the WML file checkout.wml.


Page 38 of 71 Previous Page | Next Page
Contents at a Glance
Print this Web Page | | Back to Top

Feedback Form (Expand)

What do you think about this web page?






WMLScript Tutorial Table of Contents WMLScript Tutorial Contents at a Glance Preferences - Change Color Scheme Preferences - Do Not Show Ads Previous Page Next Page