Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

CFELSE not executing

Explorer ,
Nov 30, 2012 Nov 30, 2012

I have a form with simple IF (field not blank) output field ELSE output   structures.  In the middle of processing them, ColdFusion starts skipping the CFELSE parts of these structures.

ColdFusion 10.

I don't see anything wrong with the code.

Anybody know what's going on?

Nathan Manning

1.5K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 30, 2012 Nov 30, 2012

My guess is white space.

I tend to approach problems like this with this sort of thing.

if some condition is true

output "yes"

else

output "no"

output other relevent data to help you figure out why you are in the else block.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 30, 2012 Nov 30, 2012

The test is <CFIF queryfield NEQ ""> <CFELSE>.  I am in the process of adding cfparameters defaulted to "" for the query result parameters to see if that helps...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Nov 30, 2012 Nov 30, 2012

I will buy you a pony if you stop capitalizing your tags.

Jason

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 30, 2012 Nov 30, 2012

Still looks like white space.  It also looks like you might want to output some data into your if block to see what's going on.  Maybe something like "before__" & "___after"

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 30, 2012 Nov 30, 2012

  <table width="60%" border="1" align="center" cellpadding="5" cellspacing="5">
    <tr>
      <th>Row</th>
   <th>Primary MD ID</th>
      <th>Primary MD<br>Last Name</th>
      <th>Primary MD<br>First Name</th>
      <th>Primary MD<br>Middle Name</th>
   <th>Address<br/>Line 1</th>
   <th>Address<br/>Line 2</th>
   <th>City</th>
   <th>State</th>
   <th>Zip Code</th>
   <th>Phone Number</th>
   <th>Email Address</th>
    </tr>
    <cfoutput query="SelectPrimaryInfo">
     <tr>
       <td align="center">#CurrentRow#</td>
       <td align="center">#PrimaryID#</td>
       <td>#PLName#</td>
       <td>#PFName#</td>
    <cfif PMName NEQ "">
     <td>#PMName#</td>
    <cfelse>
     <td> </td>
    </cfif>
   
    <cfif Address1 NEQ "">
     <td>#Address1#</td>
    <cfelse>
     <td>Not Provided</td>
    </cfif>
   
    <cfif Address2 NEQ "">
     <td>#Address2#</td>
    <cfelse>
     <td>Not Provided</td>
    </cfif>
   
    <cfif City NEQ "">
     <td>#City#</td>
    <cfelse>
     <td>Not Provided</td>
    </cfif>
   
    <cfif State NEQ "">
     <td>#SelectState.StateName#</td>
    <cfelse>
     <td>Not Provided</td>
    </cfif>

    <cfif Phone NEQ "">
     <td>#Phone#</td>
    <cfelse>
     <td>Not Provided</td>
    </cfif>

    <cfif Email NEQ "">
     <td><a href="#Email#mailto:#Email#">#Email#</a></td>
    <cfelse>
     <td>Not Provided</td>
    </cfif>
     </tr>
    </cfoutput>
  </table>

The <cfif Phone NEQ ""> is where the <cfelse> gets skipped.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 30, 2012 Nov 30, 2012

Put all of it into a cftry/cfcatch, then cfdump the #cfcatch#.

^_^

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Dec 02, 2012 Dec 02, 2012

Hi,

You can try the below.

<cfif Len(Phone) NEQ 0>

     <td>#Phone#</td>

    <cfelse>

     <td>Not Provided</td>

    </cfif>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 03, 2012 Dec 03, 2012

Trim.

<cfif trim(Address1) NEQ "">

<td>#Address1#</td>

<cfelse>

<td>Not Provided</td>

</cfif>

<cfif trim(Address2) NEQ "">

<td>#Address2#</td>

<cfelse>

<td>Not Provided</td>

</cfif>

<cfif trim(City) NEQ "">

<td>#City#</td>

<cfelse>

<td>Not Provided</td>

</cfif>

<cfif trim(State) NEQ "">

<td>#SelectState.StateName#</td>

<cfelse>

<td>Not Provided</td>

</cfif>

<cfif trim(Phone) NEQ "">

<td>#Phone#</td>

<cfelse>

<td>Not Provided</td>

</cfif>

<cfif trim(Email) NEQ "">

<td><a href="#Email#mailto:#Email#">#Email#</a></td>

<cfelse>

<td>Not Provided</td>

</cfif>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 03, 2012 Dec 03, 2012

I always try to use:

<cfif len(trim(Email)) neq 0>

to prevent null/blank/space errors.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 03, 2012 Dec 03, 2012
LATEST

chuckbeckwith wrote:

I always try to use:

<cfif len(trim(Email)) neq 0>

to prevent null/blank/space errors.

It's the same as <cfif trim(Email) NEQ "">

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources