Professional Web Applications Themes

query result Alternate row with different color - Coldfusion - Getting Started

:o hello can anyone help me on a query result. i wish to have a : query result Alternate row with different color . ex. first row light grey second row darker grey. and repeats itself up to the last record/row. thanks...

  1. #1

    Default query result Alternate row with different color

    :o

    hello
    can anyone help me on a query result.

    i wish to have a :
    query result Alternate row with different color .

    ex.
    first row light grey
    second row darker grey.

    and repeats itself up to the last record/row.

    thanks

    jermainestudent Guest

  2. #2

    Default Re: query result Alternate row with different color

    One possibility...

    <table>
    <cfoutput query="your_query">
    <tr bgcolor="<cfif currentrow mod 2>lightgrey<cfelse>darkgray</cfif>">
    <td>#query_field1#</td>
    <td>#query_field2#</td>
    <td>#query_field3#</td>
    </tr>
    </cfoutput>
    </table>

    etc....you get the idea

    Phil

    paross1 Guest

  3. #3

    Default Re: query result Alternate row with different color

    See below.


    <CFSET color = "dddddd">
    <TABLE>
    <CFOUTPUT QUERY="someQuery">
    <TR>
    <TD BGCOLOR="#color#">#firstName# #lastName#</TD>
    </TR>
    <CFIF color IS "dddddd">
    <CFSET color = "bbbbbb">
    <CFELSE>
    <CFSET color = "dddddd">
    </CFIF>
    </CFOUTPUT>
    </TABLE>

    jdeline Guest

  4. #4

    Default Re: query result Alternate row with different color

    where do i attached this code to.

    between?
    jermainestudent Guest

  5. #5

    Default Re: query result Alternate row with different color

    Between what? The posts are examples of two methods of altering the background
    color of a row in a table driven from the output of a query, and if you are
    unable to figure out how to implement either one in your particular instance,
    then your request is rather premature, as it seems that you aren't even
    familiar with HTML tables.

    Phil

    paross1 Guest

  6. #6

    Default Re: query result Alternate row with different color

    thanks
    i got this error.


    Variable CURRENTROW is undefined.
    jermainestudent Guest

  7. #7

    Default Re: query result Alternate row with different color

    thanks
    i got this error.


    Variable CURRENTROW is undefined.
    jermainestudent Guest

  8. #8

    Default Re: query result Alternate row with different color

    <tr> <!------------------------------I replaced with <tr bgcolor="<cfif
    currentrow mod 2>##D3D3D3<cfelse>##F5F5F5</cfif>">
    <td>
    #MYARRAY[x][2].CNO#
    </td>
    <td align="center">
    #MYARRAY[x][2].CDCDTt#
    </td>
    <td>
    #MYARRAY[x][2].PADESC#
    </td>
    <td align="center">
    #MYARRAY[x][2].INc#
    </td>
    <td align="center">
    #MYARRAY[x][2].Exp#
    </td>

    <cfset thirdArray = MYARRAY[x][3]>
    <cfif NOT arraylen(thirdArray)>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <cfelse>
    <cfloop index="z" from="1" to="3">
    <cfif z GT arraylen(thirdArray)>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <cfelse>
    <td>
    #thirdArray[z][2]#&nbsp;
    </td>
    <td>
    #thirdArray[z][3]#&nbsp;
    </td>
    </cfif>
    </cfloop>
    <cfif arrayLen(thirdArray) gt 3>
    <td nowrap="nowrap">
    <cfloop index="z" from="4" to="#arraylen(thirdArray)#">
    #thirdArray[z][2]# - #thirdArray[z][3]#<BR />
    </cfloop>
    </td>
    </cfif>
    </cfif>
    </tr>

    I got this error.
    Variable CURRENTROW is undefined


    jermainestudent Guest

  9. #9

    Default Re: query result Alternate row with different color

    <tr> <!------------------------------I replaced with <tr bgcolor="<cfif
    currentrow mod 2>##D3D3D3<cfelse>##F5F5F5</cfif>">
    <td>
    #MYARRAY[x][2].CNO#
    </td>
    <td align="center">
    #MYARRAY[x][2].CDCDTt#
    </td>
    <td>
    #MYARRAY[x][2].PADESC#
    </td>
    <td align="center">
    #MYARRAY[x][2].INc#
    </td>
    <td align="center">
    #MYARRAY[x][2].Exp#
    </td>

    <cfset thirdArray = MYARRAY[x][3]>
    <cfif NOT arraylen(thirdArray)>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <cfelse>
    <cfloop index="z" from="1" to="3">
    <cfif z GT arraylen(thirdArray)>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <cfelse>
    <td>
    #thirdArray[z][2]#&nbsp;
    </td>
    <td>
    #thirdArray[z][3]#&nbsp;
    </td>
    </cfif>
    </cfloop>
    <cfif arrayLen(thirdArray) gt 3>
    <td nowrap="nowrap">
    <cfloop index="z" from="4" to="#arraylen(thirdArray)#">
    #thirdArray[z][2]# - #thirdArray[z][3]#<BR />
    </cfloop>
    </td>
    </cfif>
    </cfif>
    </tr>

    I got this error.
    Variable CURRENTROW is undefined


    forumnotifier Guest

  10. #10

    Default Re: query result Alternate row with different color

    Doesn't look to me like you are displaying a "query" result, but the contents
    of a set of arrays. Instead of currentRow, you probably should use the value
    of the index variable of the outer loop to determine what "row" you are on.

    Phil

    paross1 Guest

Similar Threads

  1. Put query result in cells like
    By briankind in forum Coldfusion - Getting Started
    Replies: 3
    Last Post: May 10th, 04:08 PM
  2. asp alternate row color
    By Russ in forum Dreamweaver AppDev
    Replies: 2
    Last Post: April 26th, 03:18 AM
  3. Replies: 4
    Last Post: June 14th, 07:58 AM
  4. Alternate for passing parameters for dbase query?
    By Bullschmidt in forum ASP Database
    Replies: 1
    Last Post: April 14th, 01:13 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not 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