Quick References
      ADO
      ASP
      CSS2
      HTML
      JavaScript
      Jet SQL
      VBScript
      WML
      WMLScript
      WSH
      XHTML
      XML DOM
      XSLT

Features
      Knowledge Base
      Tutorials

Partners
     ZVON.ORG
     XML
     Planet Source Code
     VisualBuilder
     Web Design
     Your HTML Source
     XML/XSLT Forums
     ASPAlliance
     Scripts
     
     Programmers Heaven
     Tek-Tips Forums
     Developer Fusion
     Code Project









OPERATOR:  conditional:  ? : ;

  ? : ;  
 
The conditional operator is used to assign one of two possible values to an expression based upon the results from a boolean test applied to a specified operand.
 
The conditional operator is used in the following format:
 
expression = operand1 ? operand2 : operand3;
 
This operator behaves as follows:
  • A boolean (true or false) test is performed on operand1.
  • If the test proves true, the expression is assigned the value of operand2.
  • If the test proves false or invalid, the expression is assigned the value of operand3.
Code for ConditionalExample.wml
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
"http://www.WAPforum.org/DTD/wml_1.1.xml">
<wml>

<card id="card1">
   <p>
   conditional example
   </p>
   <do type="accept">
      <go href="ConditionalExample.wmls#findconditional()" />
   </do>
</card>

<card id="card2">
<p>
   expression = $(express)
</p>
</card>

</wml>

 
Code for ConditionalExample.wmls
extern function findconditional()
{
   var oper1;
   var oper2 = "second operand";
   var oper3 = "third operand";
   var boo = Dialogs.prompt("true, false, or invalid", "");
   if(boo == "true") oper1 = true;
   if(boo == "false") oper1 = false;
   if(boo == "invalid") oper1 = invalid;
   var exp = oper1 ? oper2 : oper3;
   WMLBrowser.setVar("express", exp);
   WMLBrowser.go("ConditionalExample.wml#card2");
};

 


Copyright 1999-2005 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information