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
for statement
while statement
STATEMENT: if else
There are two possible formats:
if
The
if
statement evaluates a specified expression contained in the
if
statement to determine if it is
true
or
false
. If
true
, a block of statements associated in the
if
statement is executed. If
false
, the
if
statement is immediately exited.
if else
The
if else
statement evaluates a specified expression contained in the
if
statement to determine if it is
true
or
false
. If
true
, the block of statements associated with the
if
statement is executed. If
false
, the block of statements associated with the
else
statement is executed. Note that you cannot provide a test expression for the
else
statement.
The block of statements executed by the
if
or
else
statement can be any legal WMLS code (including more
if
and
if else
statements).
Code for IfElseExample.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>
if else example
</p>
<do type="accept">
<go href="IfElseExample.wmls#findifelse()" />
</do>
</card>
<card id="card2">
<p>
rand is $(str)
</p>
</card>
</wml>
Code for IfElseExample.wmls
extern function findifelse()
{
var str;
var rand = Lang.random(10000);
if
(rand < 5000)
{
str = "less than 5000";
}
else
{
str = "NOT less than 5000";
}
WMLBrowser.setVar("str", str);
WMLBrowser.go("IfElseExample.wml#card2");
};
Copyright 1999-2005 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information