Solved

CFIF

Posted on 2012-03-16
4
452 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 16

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

Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

Question has a verified solution.

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

Suggested Solutions

CFGRID Custom Functionality Series -  Part 1 Hi Guys, I was once asked how it is possible to to add a hyperlink in the cfgrid and open the window to show the data. Now this is quite simple, I have to use the EXT JS library for this and I achiev…
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

740 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