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

CFELSE not executing

Explorer ,
Nov 30, 2012 Nov 30, 2012

Copy link to clipboard

Copied

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

Views

1.3K

Translate

Translate

Report

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

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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...

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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

Jason

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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"

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

  <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.

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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

^_^

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

Hi,

You can try the below.

<cfif Len(Phone) NEQ 0>

     <td>#Phone#</td>

    <cfelse>

     <td>Not Provided</td>

    </cfif>

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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>

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

I always try to use:

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

to prevent null/blank/space errors.

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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 "">

Votes

Translate

Translate

Report

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
Documentation