|
ColdFusion Home
Basic ColdFusionIntroductionColdFusion Installation ColdFusion Editors ColdFusion Syntax ColdFusion Includes ColdFusion Variables ColdFusion Variable Types ColdFusion If Statements ColdFusion Loops ColdFusion Datasource ColdFusion Database Queries ColdFusion Lists ColdFusion Arrays ColdFusion Redirect ColdFusion Debugging ColdFusion Error Handling Advanced ColdFusionColdFusion MailColdFusion Functions ColdFusion Components ColdFusion Web Services ColdFusion Upload File ColdFusion Read File ColdFusion Write File ColdFusion Append File ColdFusion Rename File ColdFusion Copy File ColdFusion Move File ColdFusion Delete File Cffile Parameters Using cffile Parameters ColdFusion FTP (cfftp) cfftp Cached Connections ColdFusion HTTP (cfhttp) ColdFusion Query of Queries ColdFusion Charts ColdFusion Summary ColdFusion AdminCF AdministratorCF Archive and Deploy CF Scheduled Tasks CF Mini Tutorial ColdFusion BooksColdFusion MX BibleMacromedia ColdFusion MX 7 Web Application Construction Kit |
ColdFusion If StatementsAs a programmer, you will often need to use conditional statements. A conditional statement is a piece of code that does one thing based on one condition, and another based on another condition. In fact, you could have as many conditions as you like. ColdFusion If statements are an example of conditional statements. With If statements, you can tell the ColdFusion server to execute a piece of code only if a given condition is true. Example If StatementIn this example, the text "Still haven't found what I'm looking for." only gets displayed if the condition is met (that the value of the variable "firstName" equals "Bono". The letters eq are used with cfif to test that a something is equal to something.
Display in browser:
Still haven't found what I'm looking for.
"If Else" StatementYou can use the cfelse tag to do something if the condition is not met.
Display in browser:
Choose your own song then...
Example "If Else If" StatementYou can use the cfelseif tag to perform another test (only if the preceeding condition/s is/are not met).
Display in browser:
Crazy Train!
NOT Equal To?Just as eq stands for equal to, neq stands for not equal to.
Display in browser:
Crazy Train!
Less Than?You can use lt to test that a value is less than another.
Display in browser:
Don't give up your day job!
Greater Than?You can use gt to test that a value is greater than another.
Display in browser:
Give up your day job!
Greater Than Or Equal To/Less Than Or Equal To?You can use gte to test that a value is greater than or equal to another. You can use lte to test that a value is less than or equal to another.
Display in browser:
Give up your day job!
|
Need Website Content?
Get unique, quality digital content for your website.
|