Title: Custom color for data using JavaScript
Last modified: August 31, 2016

---

# Custom color for data using JavaScript

 *  Resolved [thevukaslt](https://wordpress.org/support/users/thevukaslt/)
 * (@thevukaslt)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/custom-color-for-data-using-javascript/)
 * Hi,
    First of all, this plugin is awesome and very useful. Thanks author for 
   developing it. 🙂
 * My idea from very beginning was build a database using Google Sheets instead 
   MySQL. I had some parts of code and begun with clean HTML page to finish writing.
   I though firstly I should bring it live and then try implementing to WordPress
   page. Sadly it was expensive and worthless as I found this plugin would do everything
   except coloring from original code. But I’m not writing to share my story.
 * The thing I want is to color table to two colors depending on text on B column.
   So if Yes, then Green, else Red.
 * Exception from original code [(here)](https://www.sperohub.io/gamesdb/) for coloring:
 *     ```
       function highlightRow(data, row, color) {
       var x;
       for(x=0; x<data.getNumberOfColumns(); x++) {
         data.setCell(row, x, undefined, undefined, {style: "background-color: " + color});
       }
       }
       var data = response.getDataTable();
       for(x=0; x<data.getNumberOfRows(); x++) {
         if(data.getValue(x, 2).match(/yes/i)) {
           highlightRow(data, x, "#9dff9d");
         } else {
           highlightRow(data, x, "#ff9d9d");
         }
       }
       ```
   
 * So I want this for the table which is now ([here](https://www.sperohub.io/games-monetization-database/))
   in WordPress, how I can do this?
 * Thanks in advance!
 * [https://wordpress.org/plugins/inline-google-spreadsheet-viewer/](https://wordpress.org/plugins/inline-google-spreadsheet-viewer/)

Viewing 6 replies - 1 through 6 (of 6 total)

 *  Plugin Author [Meitar](https://wordpress.org/support/users/meitar/)
 * (@meitar)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/custom-color-for-data-using-javascript/#post-7000261)
 * See [https://wordpress.org/support/topic/conditional-styling?replies=2](https://wordpress.org/support/topic/conditional-styling?replies=2)
 *  Thread Starter [thevukaslt](https://wordpress.org/support/users/thevukaslt/)
 * (@thevukaslt)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/custom-color-for-data-using-javascript/#post-7000294)
 * Okay, could you, please, explain what code write to DataTables defaults object
   box (this is only table I’m using plugin for)? Or should I write it somewhere
   else? 🙂
 *  Plugin Author [Meitar](https://wordpress.org/support/users/meitar/)
 * (@meitar)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/custom-color-for-data-using-javascript/#post-7000296)
 * This is custom code you need to write yourself, specifically because you are 
   inspecting the content of the cells.
 *  Thread Starter [thevukaslt](https://wordpress.org/support/users/thevukaslt/)
 * (@thevukaslt)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/custom-color-for-data-using-javascript/#post-7000297)
 * Sorry for that dumb question. I’m trying to insert it to page, so everything 
   looks almost fine except it changes the whole page.
 * I believe this part should be adjusted to specific rows (which contain: Yes)
   `
   $<strong>( "div:contains('Yes')" )</strong>.css( "color", "green" );`
 * When what should I put instead div, to affect only those rows? 🙂
 * (I did not saw your last post before posting this out, however that doesn’t change
   much)
 *  Plugin Author [Meitar](https://wordpress.org/support/users/meitar/)
 * (@meitar)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/custom-color-for-data-using-javascript/#post-7000298)
 * Sorry, I don’t write or assist with custom code here. There are literally thousands
   of other places on the Internet to ask general questions about how to use jQuery.
 *  Thread Starter [thevukaslt](https://wordpress.org/support/users/thevukaslt/)
 * (@thevukaslt)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/custom-color-for-data-using-javascript/#post-7000328)
 * I see, thanks for all above anyway. 🙂

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Custom color for data using JavaScript’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/inline-google-spreadsheet-viewer.
   svg)
 * [Inline Google Spreadsheet Viewer](https://wordpress.org/plugins/inline-google-spreadsheet-viewer/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/inline-google-spreadsheet-viewer/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/inline-google-spreadsheet-viewer/)
 * [Active Topics](https://wordpress.org/support/plugin/inline-google-spreadsheet-viewer/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/inline-google-spreadsheet-viewer/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/inline-google-spreadsheet-viewer/reviews/)

## Tags

 * [column](https://wordpress.org/support/topic-tag/column/)
 * [datatables](https://wordpress.org/support/topic-tag/datatables/)
 * [rows](https://wordpress.org/support/topic-tag/rows/)

 * 6 replies
 * 2 participants
 * Last reply from: [thevukaslt](https://wordpress.org/support/users/thevukaslt/)
 * Last activity: [10 years, 3 months ago](https://wordpress.org/support/topic/custom-color-for-data-using-javascript/#post-7000328)
 * Status: resolved