I'm torn between taking the time to refactor this or just get it done and into production (I'm sure nobody else ever has that problem), but this code is turning really ugly and I'm not sure how to fix it.
My
JSP generates a table that looks like this:
Each of those white cells must have the value compared to the goal and then the cell is colored green if the actual is equal to or less than the goal, or red if it's over goal.
I'm currently doing it with this function:
I know, I can make "missedgoal" the default and just turn the green ones, but this helps me debug. I'll do that when it's almost finished.
The function is called like so:
By now you can see the problem; this function has to be called for every cell. The repetition is killing me, but I can't think of a good way to do this with a loop.
How do I collect those elements and pass them into a loop? I considered making an object with those three properties but I'm not sure how to populate an array of objects that can be looped over.
The JSP looks like so. I'm using the hidden fields to store the unformatted values.
Any suggestions on how to tame this beast?