Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

query result Alternate row with different color

New Here ,
May 23, 2006 May 23, 2006


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
TOPICS
Getting started
969
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
May 23, 2006 May 23, 2006
One possibility...

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

etc....you get the idea

Phil
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 24, 2006 May 24, 2006
thanks
i got this error.


Variable CURRENTROW is undefined.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 24, 2006 May 24, 2006
thanks
i got this error.


Variable CURRENTROW is undefined.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 24, 2006 May 24, 2006
<tr> <!------------------------------I replaced with <tr bgcolor="<cfif currentrow mod 2>##D3D3D3<cfelse>##F5F5F5</cfif>">
<td>
#MYARRAY[2].CNO#
</td>
<td align="center">
#MYARRAY[2].CDCDTt#
</td>
<td>
#MYARRAY[2].PADESC#
</td>
<td align="center">
#MYARRAY[2].INc#
</td>
<td align="center">
#MYARRAY[2].Exp#
</td>

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

I got this error.
Variable CURRENTROW is undefined
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 24, 2006 May 24, 2006
<tr> <!------------------------------I replaced with <tr bgcolor="<cfif currentrow mod 2>##D3D3D3<cfelse>##F5F5F5</cfif>">
<td>
#MYARRAY[2].CNO#
</td>
<td align="center">
#MYARRAY[2].CDCDTt#
</td>
<td>
#MYARRAY[2].PADESC#
</td>
<td align="center">
#MYARRAY[2].INc#
</td>
<td align="center">
#MYARRAY[2].Exp#
</td>

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

I got this error.
Variable CURRENTROW is undefined
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
May 23, 2006 May 23, 2006
See below.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 24, 2006 May 24, 2006
where do i attached this code to.

between?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
May 24, 2006 May 24, 2006
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. How were you planning on displaying your query output?

Phil
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
May 24, 2006 May 24, 2006
You need to use the query name - queryName.currentRow - in your CFIF statement.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
May 24, 2006 May 24, 2006
LATEST
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
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources