0

Guys,

I have a dynamic HTML table which gets populated by coldfusion and displayed in the page, I
have a column called performace which holds numeric values. I need to select the
top 3 best performace value in the column and then highlight the entire row in
different colours (top 3 values for performance). Can any one help me in doing it?

My server can run only Javascript and coldfusion, No Ajax/PHP.

I need a complete set of code which such that I will add the script and it performs the calculating and highlighting part.


Appreciate for a faster and a completed coding response :-) !!!

Thanks,
Ashok Ramkumar

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by fxm
0

Set up three styles

tr.tr1 td {color:}
  tr.tr2 td {color:}
  tr.tr3 td {color:}

to be applied to the winning rows.

Assuming that you don't want to sort the table (which makes the task almost trivial) use getElementsByTagName('tr') to create a collection of pointers to the rows.

Extract the key value from the proper 'td' of each row and add that value [with matching row number] to an array.

Sort that array on the values. (The sort might be avoided by building the list of winners as you go, but code for that approach is more complicated.)

For the top 3 [what if there are less than 3? what about ties?] add the appropriate style name (tr1, tr2, tr3) to the className attribute of the matching row.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.