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
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.
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...
Copy link to clipboard
Copied
I will buy you a pony if you stop capitalizing your tags.
Jason
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"
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.
Copy link to clipboard
Copied
Put all of it into a cftry/cfcatch, then cfdump the #cfcatch#.
^_^
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>
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>
Copy link to clipboard
Copied
I always try to use:
<cfif len(trim(Email)) neq 0>
to prevent null/blank/space errors.
Copy link to clipboard
Copied
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 "">