Change background color of HTML table cell depending on drop-down list value?

html change text color based on value
change row color based on cell value javascript
javascript change background color based on value
javascript change table row background color
javascript if statement change background color
javascript conditional background color
javascript conditional formatting table cell
html conditional font color

<!DOCTYPE html>
<html>
<header>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<style>
.MRG{ background-color:#82E0AA; }
.MRA{ background-color:#F5B041; }
.MRR{ background-color:#EC7063; }
</style>
</header>
<body>
<table class="table table-hover table-condensed" border="1px">
  <thead>
    <tr>
	  <td>Made Ready</td>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>
	  <select>
		<option class="MRR">Red</option>
		<option class="MRA">Amber</option>
		<option class="MRG">Green</option>
	  </select>
	  </td>
    </tr>
  </tbody>
</table>
</body>
</html>

Is this what you're looking for ?

document.querySelector('select').onchange=changeEventHandler;

var indicator = document.getElementById("color-indicator");

function changeEventHandler(event) {
    indicator.classList = this.value;
}
.MRG{ background-color:#82E0AA; }
.MRA{ background-color:#F5B041; }
.MRR{ background-color:#EC7063; }
<table class="table table-hover table-condensed" border="1px">
  <thead>
    <tr>
	  <td>Made Ready</td>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td id="color-indicator">
        <select>
          <option value="MRR">Red</option>
          <option value="MRA">Amber</option>
          <option value="MRG">Green</option>
        </select>
      </td>
    </tr>
  </tbody>
</table>

Within a table, change color of row based on drop-down field , All this does is check the value of the drop down and either add or remove the "​RedRow" class to the parent "tr" element. When the class is added  Then select “Format only cells that contain,” then in the first drop down select “Cell Value” and in the second drop-down select “Between.” Then, on the first box enter 0 and in the second box enter 10, then click on the Format button and go to Fill Tab, select the blue color, click ok and again click ok.

  <html>
  <header>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

  </header>
  <body>
  <table  id="myTable" class="table table-hover table-condensed" border="1px">
    <thead>
      <tr>
      <td>Made Ready</td>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td>
      <select id="mySelect" onchange="abc()">
      <option value="red" class="MRR">Red</option>
      <option value="yellow"   class="MRA">Yellow</option>
      <option  value="green"  class="MRG">Green</option>
      </select>
      </td>
      </tr>
    </tbody>
  </table>
  <script>
    function abc(){
        document.getElementById("myTable").style.backgroundColor = document.getElementById("mySelect").value
    }
  </script>
  </body>
  </html>

Demo https://jsfiddle.net/95wvnh0x/7/

Change html table cell color depending on its value javascript, Mar 30, 2017 · Change Background Color On Click - HTML CSS and Javascript Is it possible to change color of table cell depending on the dropdown input? For Styler. get class list of an element. table -based tables look in Bootstrap. In HTML, table background color is defined using Cascading Style Sheets (CSS). Specifically, you use the background-color property to define background color. You can apply this property against the whole table, a row, or a single cell. Below are some examples of applying background color to a table in HTML.

Assign 'id's to your and the target , then use something like this:

<select id="mySelect">...</select>
<td id="myCell">...</td>
<script>
    document.getElementById('mySelect').addEventListener('change', function (event) {
        document.getElementById('myCell').className = event.target.value;
    });
</script>

Is it possible to change color of table cell depending on the , In my dashboard, I have to highlight the cells that have a value greater than the CSS is applied through hidden <html> pane (using depends attribute with a token <label>Change Table Cell Colors based on Drop Down</label>; <​fieldset #table1 td.range-low {; background-color: #65A637 !important;; }  A Drop Down list lets you control what the user enters in a worksheet, click the black arrow next to the cell to expand the list. The list shows valid values the user can select, simply click on a value with the mouse or use up/down arrow keys. Select cell D3. Go to tab "Data" on the ribbon. Click "Data Validation" button on the ribbon and a

With only three lines: 




    <!DOCTYPE html>
    <html>
    <header>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <style>
    .MRG{ background-color:#82E0AA; }
    .MRA{ background-color:#F5B041; }
    .MRR{ background-color:#EC7063; }
    </style>
    </header>
    <body>
    <table class="table table-hover table-condensed" border="1px">
      <thead>
        <tr>
    	  <td>Made Ready</td>
        </tr>
      </thead>
      <tbody>
<!-- Add class name for tr -->
        <tr class="changeColor">
          <td>
<!-- Add id  for select -->
    	  <select id="colorChanger">
    		<option class="MRR">Red</option>
    		<option class="MRA">Amber</option>
    		<option class="MRG">Green</option>
    	  </select>
    	  </td>
        </tr>
      </tbody>
    </table>

<!-- Add this script -->
<script>
$('#colorChanger').on('change', function() {
$('.changeColor').addClass($('#colorChanger :selected').attr('class'));
});
</script>

    </body>
    </html>

Javascript change table row background color based on value, CSS Table Background color Change HTML table cell color based on value Hi, to writing one line of code to change the selected value from a drop-down list. Select the option List in Allow and select the source list in Source option and click OK. A dropdown list will be created on the cell. Now click Home > Conditional formatting. Select New rule from the list and a dialog box will appear. Select Specific Text option and select the cell for colour as in this case Red. Select Format > Fill option.

HTML td tag, The <td> tag defines a standard cell in an HTML table. An HTML table Attribute, Value, Description How to add background-color to table cell (with CSS):. For finishing this task, we need to create a drop down list first, and then apply the Conditional Formatting to color the cells. Please do as following steps: First, create a drop down list: 1. Create a list of data and select a range that you want to put the drop down list values into.

<tr>: The Table Row element, The HTML tr element defines a row of cells in a table. If no value is expressly set for align , the parent node's value is To apply character-based alignment, set the CSS text-align property to To give a similar effect as the bgcolor attribute, use the CSS property background-color . Let's break it down. change table cells color based on value. check if element is visible in viewport. display auto fade out message. fitvids.js for automatically resizing videos. get class list of an element. jQuery toggleClass() examples. make a div stick at top on scroll. table with alternate color rows.

Applying color to HTML elements using CSS, With CSS, there are lots of ways to add color to your HTML elements to of how to use color wisely: how to select appropriate colors, keeping in mind the For each, we'll see a list of the CSS properties that apply color to them. color (which is then blurred and blended with the background based on the  There is no value in the cells, I just want to change the color from green to gray.Any help would be great. Re: Change color of cell based on drop down selection you can do this with conditional formatting. if you are unfamiliar with it, find it on the home tab under styles.

Comments
  • you should ask, if jQuery is an option
  • OP's code has jquery include in it, although it should of been tagged with it as well
  • What do you mean ? If question is how to achieve this with jQuery ? (edited, removed jQuery)
  • @NicossB Sorry, I overlooked, that OP has already included jQuery. Take my upvote then :)