Solved

CFIF

Posted on 2012-03-16
4
447 Views
Last Modified: 2012-06-27
Experts,

Based on the code below, If my varibale (isMyVariable) is true then I need to use one CFIF, if not other CFIF. Here is what I am doing and throws me the

Context validation error for the cfelse tag.  
The tag must be nested inside a CFIF tag.  

What is the best way to hanlde thing?


<cfif isMyVariable EQ "True">
            <cfif ((variables.Variable1 NEQ Myquery1.Column1) AND (variables.Variable2 NEQ Myquery2.Column1))>
<cfelse>            
            <cfif ((variables.Variable1 NEQ Myquery3.Column1) AND (variables.Variable2 NEQ Myquery4.Column1))>
</cfif>
                  My Other Code for the big CFIF
            <cfelse>
                  Rest of the code            
            </cfif>


Thanks and appreciate your quick help.
0
Comment
Question by:Tpaul_10
  • 2
4 Comments
 
LVL 19

Assisted Solution

by:erikTsomik
erikTsomik earned 125 total points
ID: 37730507
based on this your are missing the closing </cfif>


<cfif isMyVariable EQ "True">
            <cfif ((variables.Variable1 NEQ Myquery1.Column1) AND (variables.Variable2 NEQ Myquery2.Column1))>
           <cfelse>            
            <cfif ((variables.Variable1 NEQ Myquery3.Column1) AND (variables.Variable2 NEQ Myquery4.Column1))>
            </cfif>
</cfif>
                  My Other Code for the big CFIF
            <cfelse>
                  Rest of the code            
            </cfif>
0
 
LVL 4

Assisted Solution

by:JohnHowlett
JohnHowlett earned 250 total points
ID: 37730510
You've opened too many cfif's without closing them


<cfif isMyVariable EQ "True">
            <cfif ((variables.Variable1 NEQ Myquery1.Column1) AND (variables.Variable2 NEQ Myquery2.Column1))>
            </cfif>
<cfelse>            
            <cfif ((variables.Variable1 NEQ Myquery3.Column1) AND (variables.Variable2 NEQ Myquery4.Column1))>
             </cfif>
            My Other Code for the big CFIF
<cfelse>
            Rest of the code            
 </cfif>
0
 
LVL 4

Assisted Solution

by:JohnHowlett
JohnHowlett earned 250 total points
ID: 37730542
Or rather:

<cfif isMyVariable EQ "True">
            <cfif ((variables.Variable1 NEQ Myquery1.Column1) AND (variables.Variable2 NEQ Myquery2.Column1))>
            </cfif>
<cfelse>            
            <cfif ((variables.Variable1 NEQ Myquery3.Column1) AND (variables.Variable2 NEQ Myquery4.Column1))>
             </cfif>
            My Other Code for the big CFIF
 </cfif>

      Rest of the code
0
 
LVL 15

Accepted Solution

by:
Gurpreet Singh Randhawa earned 125 total points
ID: 37732064
rather this way:

<cfif isMyVariable EQ "True">
            <cfif ((variables.Variable1 NEQ Myquery1.Column1) AND (variables.Variable2 NEQ Myquery2.Column1))>
            </cfif>
<cfelseif isMyVariable EQ "False">            
            <cfif ((variables.Variable1 NEQ Myquery3.Column1) AND (variables.Variable2 NEQ Myquery4.Column1))>
             </cfif>
<cfelse>
            My Other Code for the big CFIF
 </cfif>
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently while working on a project I got a very annoying cfdocument has no body error message. I had never seen this error before. So I checked the code. The code was pretty simple; it was Just showing me the cfdocumnt tag and inside that tag a …
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

930 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now