cfscript - if else conditional statement in script
cfscriptIfElse.cfm
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>How to use if else conditional statement in cfscript tag</title>
</head>
<body>
<h2 style="color:DodgerBlue; font-style:italic">cfscript example: if else</h2>
<hr width="350" align="left" color="PaleVioletRed" />
<br />
<cfform name="HelloForm" method="post">
Name:
<cfinput type="text" name="UserName">
<cfinput name="Submit" type="submit" value="Submit">
</cfform>
<br />
<cfscript>
if (IsDefined("Form.Submit"))
{
if (Form.UserName neq "")
{
WriteOutput("Hello ");
WriteOutput(Form.UserName);
}
else
WriteOutput("Please input your name");
}
</cfscript>
</body>
</html>