not showing a field if empty

Ask a Question related to Macromedia ColdFusion, Design and Development.

  1. #1

    Default not showing a field if empty

    Hi

    I have database query and the results are displayed on a page, now some of the
    fields are empty and they take up space.
    I wanted to know if anyone here knows any code that WILL NOT display these
    empty fields?? so blank white spaces do NOT appear.

    any help would be useful.
    kamesh

    Kamesh192 Guest

  2. Similar Questions and Discussions

    1. Make Calculation Field empty not zero
      Using Acrobat Pro 6 is there a way to have a calculation field not default to zero 0.00 but rather remain empty? I would like to have it be empty if...
    2. determine empty field
      I have a page that has a timer. Click a button, and the current time is inserted in a field, click another button and the current time is inserted...
    3. ntext field not showing up (ASP)
      I changed the datatype of a field in a SQL Server 2000 database from nvarchar to ntext, but now nothing is being displayed. The "Body" column of...
    4. CustomControl - Not triggering on an empty field.
      Hi, I've made a serverside component that automatically adds a validator. Currently i have both a REQUIRED validator and a CUSTOM validator in...
    5. Finding Empty Field
      When I use the * in a field in a find request to find or omit records that have no data in the field, I get the following error message: This...
  3. #2

    Default Re: not showing a field if empty

    Hi Kamesh

    If you are using the Table with some TR and TD's then if one column does not
    have the value then obviously it will displays the empty space on that place.

    or else if you are displaying the values directly on the page then you can
    check the length of the each field.
    if the length is GT 0 then display the value other wise display nothing.
    then you wont get any spaces or something else.


    vkunirs Guest

  4. #3

    Default Re: not showing a field if empty

    hi
    thanks vkunirs.
    i am not using tables, the fields are listed on the page serparately.
    could you possible tell me where i put "gt 0" for it to affect the query, not
    just one field or do i have to put "gt 0" for every field? also do i put "gt 0"
    in a <cfif> tag?

    sorry, but i am a beginner to all this
    below is my code:
    <cfoutput>#rsPrint.location#</cfoutput><br>
    <br>
    <cfoutput>#rsPrint.DESCRIPTION#</cfoutput><br>
    <br>
    <cfoutput>#rsPrint.short_description#</cfoutput><br>
    <br>
    <cfoutput>#rsPrint.MINI_IMAGE#</cfoutput><br>
    <br>
    <cfoutput>#rsPrint.OPEN_TIMES#</cfoutput><br>
    <br>
    <cfoutput>#rsPrint.LINK1#</cfoutput><br>
    <br>
    <cfoutput>#rsPrint.LINK2#</cfoutput> <br><br>
    <cfoutput>#rsPrint.LINK3#</cfoutput><br><br>
    <cfoutput>#rsPrint.SEASONS#</cfoutput><br><br>
    <cfoutput>#rsPrint.EVENTS#</cfoutput><br><br>
    <cfoutput>#rsPrint.CONTACT#</cfoutput><br><br>
    <cfoutput>#rsPrint.INFO_NUMBER#</cfoutput><br><br>
    <cfoutput>#rsPrint.XTRA_INFO#</cfoutput><br><br>
    <cfoutput>#rsPrint.FACILITIES#</cfoutput><br><br>
    <cfoutput>#rsPrint.GRID_REF#</cfoutput><br><br>
    <cfoutput>#rsPrint.IMAGE1#</cfoutput><br><br>
    <cfoutput>#rsPrint.COST#</cfoutput><br><br>
    <cfoutput>#rsPrint.IMAGE2#</cfoutput><br><br>
    <cfoutput>#rsPrint.IMAGE3#</cfoutput><br><br>

    thanks
    kamesh

    Kamesh192 Guest

  5. #4

    Default Re: not showing a field if empty

    i did one for you:

    <cfoutput query="rsPrint">
    <cfif trim(len(location))>
    #location#<br>
    <br>
    </cfif>
    #DESCRIPTION#<br>
    <br>
    #short_description#<br>
    <br>
    #MINI_IMAGE#<br>
    <br>
    #OPEN_TIMES#<br>
    <br>
    #LINK1#<br>
    <br>
    #LINK2# <br><br>
    #LINK3#<br><br>
    #SEASONS#<br><br>
    #EVENTS#<br><br>
    #CONTACT#<br><br>
    #INFO_NUMBER#<br><br>
    #XTRA_INFO#<br><br>
    #FACILITIES#<br><br>
    #GRID_REF#<br><br>
    #IMAGE1#<br><br>
    #COST#<br><br>
    #IMAGE2#<br><br>
    #IMAGE3#<br><br>
    </cfoutput>

    PaulH Guest

  6. #5

    Default Re: not showing a field if empty

    hi
    thanks Paul
    I put ur code into my page but the problem still exists.
    if u look at the page [url]http://www.greengrid.co.uk/printer_friendly.cfm?id=97[/url]
    ull see gaps along the page- these are the empty fields.

    i dont know if i explained myself clear, basically i dont want empty fields to
    be displayed.???

    all help welcome!
    thanks
    kamesh

    Kamesh192 Guest

  7. #6

    Default Re: not showing a field if empty

    and did you apply that cfif logic to all your fields? and did you include the <br> as well?
    PaulH Guest

  8. #7

    Default Re: not showing a field if empty

    Hi

    try like this if possible.

    <cfoutput query="s">
    <cfloop list="#s.columnlist#" index="i">
    <Cfif #len(evaluate(i))# gt 0>
    #evaluate(i)#<br>
    </Cfif>
    </cfloop>
    </cfoutput>

    Here it will check for the each field info and if the field is empty it wont
    display anything.
    else it will display those info which is in the field.

    This works fine for your requirement.
    I hope it will works 4 u



    vkunirs Guest

  9. #8

    Default Re: not showing a field if empty

    hi
    thanks paul and vkunirs
    it was a upload issue, for some reason the file kept being displayed.
    i haved used pauls method and works perfectly.

    thanks to both of u for ur help
    kamesh
    Kamesh192 Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139