Showing posts with label red. Show all posts
Showing posts with label red. Show all posts

Sunday, October 28, 2012

Javascript table red if negative

"How do I make a table show red in a cell if negative?"

There are likely a few things to watch out for (a minus in a text name or something like that.)


        //quick cheat red if negative.
        var table = document.getElementById("my_table");
        for (var j=0, row; row=table.rows[j]; j++) {
                for (var i=0, cell; cell= row.cells[i]; i++) {
                        if (cell.innerText.indexOf("-")>-1) {
                                cell.style.color="red";
                        }
                }
        }

Monday, July 16, 2012

cakephp success is red?

"Why is all setFlash red? Can't we do a success in green?"

Well, yes, just change the successful to look like this.
 $this->Session->setFlash(__('The information has been saved'), 'default', array('class' => 'success'));

This assumes you're using cake's default css.

If, incidentally, you want to bake it ...
copy lib/Cake/Console/Templates/default/actions/controller_actions.ctp to app/Console/Templates/default/actions/controller_actions.ctp and make similar changes to "has been saved" entries (there are two?)

$this->Session->setFlash(__('The has been saved'), 'default', array('class' => 'success'));



incidentally, setting up this custom will break other bakes. If you want to keep the functionality, you can either copy "default/classes" and default/views" or 
ln -s /path/to/lib/Cake/Console/Templates/default/classes app/Console/Templates/default/classes
ln -s /path/to/lib/Cake/Console/Templates/default/views app/Console/Templates/default/views

(I recommend symlinks if possible just in case updates in the templates from source need to trickle down.) 

YMMV, hope it helps someone.

Blog Archive