Using <CFELSEIF> So far, we have only been able to check for two conditions. If we want to check for more than two conditions, we can use the <CFELSEIF> tag. The <CFELSEIF> tag enables you to string together as many choices as you need. If Dad were to use the following code, he could be as obsessive about his car as he likes. <CFIF CarDented IS "YES"> <!--- code to automate the kicking of Barry's backside---> <CFELSEIF EmptyBeerCansInTrunk IS "Yes"> Night in 'The Box' <CFELSEIF AshesInAshtray IS "Yes"> Barry is grounded <CFELSE> Eye Barry suspiciously and check the quantity of fuel in the gas tank </CFIF> By using <CFELSE>, dear old Dad could have put the car through a 12-point safety check (or as many points as he liked) every time I brought it home. However, as soon as the first condition evaluated to TRUE, that bit of code would have been run and the rest of the comparisons skipped. For example, if Dad had found empty beer cans in the trunk, I would have been off for a night in "The Box" Cool Hand Luke style, and Dad wouldn't have even bothered to check the ashtray. The <CFELSEIF> tags must go after the opening <CFIF> tag and before the <CFELSE> tag. The <CFELSE> tag must be used for the last condition to be checked. |