Skip navigation
Currently Being Moderated

CFELSE not executing

Nov 30, 2012 10:59 AM

Tags: #cf10

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

 
Replies
  • Currently Being Moderated
    Nov 30, 2012 11:02 AM   in reply to NatheManning

    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.

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 30, 2012 11:41 AM   in reply to NatheManning

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

     

    Jason

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 30, 2012 11:57 AM   in reply to NatheManning

    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"

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 30, 2012 12:31 PM   in reply to NatheManning

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

     

    ^_^

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 2, 2012 10:48 PM   in reply to NatheManning

    Hi,

    You can try the below.

     

    <cfif Len(Phone) NEQ 0>

         <td>#Phone#</td>

        <cfelse>

         <td>Not Provided</td>

        </cfif>

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 3, 2012 1:02 AM   in reply to NatheManning

    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>

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 3, 2012 9:34 AM   in reply to BKBK

    I always try to use:

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

    to prevent null/blank/space errors.

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 3, 2012 10:19 PM   in reply to chuckbeckwith

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

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points