Using CF IIF with Javascript Functions

I get bored writing CFIF statements so thought I would try using the old IIF method. Despite the arguments about performance it works quite well if you are not running it through thousands of iterations. I also had need to call a javascript function if a variable met some criteria. This is a simplified example.

<cfset myvar = "abc">
<cfoutput>
#iif(myvar is "abc",
DE("<script>getx('a');</script>"),
DE("<script>getx('Z');</script>")
)#
</cfoutput>

getx(val) is a javascript function in my head tags.

Cup size   
Select size then click on coffee cup.
This entry was posted in Code, Coldfusion, Snippets. Bookmark the permalink.