garyttu
asked on
Highlighting changes between table rows
Let's say I have 2 rows in a SQL table. The second is a copy of the first only one or two columns are now changed. Basically I have created a revision of row one but want to keep the original row as well.
I output this new row of data to an CFM page- only I want to highlight the changes to the row by highlighting the output in red. Is there anyway to do this on the fly for each cfoutput? Basically I don't want to have to do a CFIF for EVERY output to compare column data of each row and change the text color inside the cfif if it has changed (or change the CSS style). Not sure if this is the only way but it sure seems cumbersome and seems like it would be unnecessarily long code....
I output this new row of data to an CFM page- only I want to highlight the changes to the row by highlighting the output in red. Is there anyway to do this on the fly for each cfoutput? Basically I don't want to have to do a CFIF for EVERY output to compare column data of each row and change the text color inside the cfif if it has changed (or change the CSS style). Not sure if this is the only way but it sure seems cumbersome and seems like it would be unnecessarily long code....
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Forced accept.
Computer101
EE Admin
Computer101
EE Admin
<cfset columnlist = "column1,column2,column3">
<cfloop query="query1">
<cfset bgcolor="white">
<cfloop list="columnlist" index="i">
<cfif query1[i] neq query2[i]>
<cfset bgcolor = "red">
</cfif>
</cfloop>
<tr bgcolor="#bgcolor#">
<cfloop list="columnlist" index="i">
<td>#query1[i]#</td>
</cfloop>
</tr>
</cfloop>