Skip to main content
Inspiring
May 10, 2008
Answered

Cannot seem to check for blanks

  • May 10, 2008
  • 3 replies
  • 642 views
My sql table has a field that I need to check to see if there is something in there or not. If it is not blank, then I want to display the value, if it is blank, then I want to dispaly None.

I usually just check for field is "", but for some reason, this time it is not working, the display comes out blank instead of None.

Here is the code I am using, with   and "", but neihter of them work :

<tr>
<td align="right">Supplier Division: </td>
<cfif sn_detail.division_name is " ">
<td align="left">None</td>
<cfelse>
<td align="left">#division_name#</td>
</cfif>
</tr>

What am I doing wrong, or what other method/technique can I use ?

(I event tried the #len but that did not work,but maybe I did not do it righ)
    This topic has been closed for replies.
    Correct answer BKBK
    <cfif trim(sn_detail.division_name) is "">
    or
    <cfif len(trim(sn_detail.division_name)) eq 0>

    3 replies

    BKBK
    Community Expert
    Community Expert
    May 12, 2008
    poger67 wrote:
    Is there any real difference between using:
    <cfif len(trim(sn_detail.division_name)) is 0>
    vs.
    <cfif NOT LEN(TRIM(sn_detail.division_name))>


    In the second case Coldfusion has to cast from integer type to boolean. However, they're both valid code.


    BKBK
    Community Expert
    BKBKCommunity ExpertCorrect answer
    Community Expert
    May 10, 2008
    <cfif trim(sn_detail.division_name) is "">
    or
    <cfif len(trim(sn_detail.division_name)) eq 0>
    May 10, 2008
    trojnfn, I saw another post of yours stating you werent a programmer, however... you are doing programming. Dont take this the wrong way, but a CF book would really help you out and probably answer a lot of your questions.

    In the meantime, try something like this:
    <tr>
    <td align="right">Supplier Division: </td>
    <cfif sn_detail.division_name is ""><!--- remove the   --->
    <td align="left">None</td>
    <cfelse>
    <td align="left">#division_name#</td>
    </cfif>
    </tr>

    trojnfnAuthor
    Inspiring
    May 10, 2008
    Yes, I am not a progarmmer attempting to do programming. I am self taught (yes, I do have the books but sometimes do not understand and need explainations) but as you can tell, not good at all. So I have to post here for help. Nobody else in the office can help.

    I did try <cfif sn_detail.division_name is ""> (this is what I usually use) and the display still comes out blank, not None. I verified that this column is blank in the table.

    Why does this not work, and any other ways to do this ?