Reputation: 435
I am displaying results in a table after looping through a query. For TestNumber
, there are some results in my query where the number is not present and
hence I want to display N/A
instead of just blank in the table. So, I am checking the existence
using IsDefined
, but for some reason it keeps on printing N/A
everytime.
<cfloop query="GetMyList1">
<tr>
<td align="center">#TestName#</td>
<cfif IsDefined(TestNumber) >
<td align="center">#TestNumber#</td>
<cfelse>
<td align="center">N/A</td>
</cfif>
<td align="center">#Date#</td>
</tr>
</cfloop>
Upvotes: 1
Views: 46
Reputation: 14333
You would want to check if there is a length of the item. The field exists, so isDefined
will always return true
<cfloop query="GetMyList1">
<tr>
<td align="center">#GetMyList1.TestName#</td>
<td align="center"><cfif len(trim(GetMyList1.TestNumber))>#GetMyList1.TestNumber#<cfelse>N/A</cfif></td>
<td align="center">#GetMyList1.Date#</td>
</tr>
</cfloop>
Upvotes: 2