Skip to content
Advertisement

I want to add a color to the highest number in the column row on the table [closed]

Original Version enter image description here

What I expect enter image description here

I need to do my table like this but I don’t know JavaScript and I need some help about that.

Numbers are always changing

They said it could be done with JavaScript or PHP, but I couldn’t do it with php. Since I have no knowledge of JavaScript, I wanted to consult you.

JavaScript

Advertisement

Answer

While SO isn’t the place for getting people to do code for you, this was a fun challenge, so I couldn’t help myself, sorry.

I agree that this should be done serverside for convenience (and maybe even for performance(?)), but here is a Javascript solution.

I hardcoded the random php values, but you can just replace all numbers again with <?php echo rand(100,1500); ?> or use your own (it will still work with your original php/html).

JavaScript
JavaScript

If you need the code to be more robust, you should give the queried elements an id or data-attribute or some other unique identifier and query that, eg.:

JavaScript
JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement