I have been trying to search for things similar to what I want but can't seem to get the exact solution. I am in no way a HTML coder, but I have to do some work in HTML, so I am learning. I understand that my code is probably a bit messy/unneeded, so please forgive me. I have managed to find some similar javascript so you will see this below.
- First I have a table created with select boxes and text areas inserted into the cells.
- The select boxes are generated from MySQL (so am using PHP also).
- When I select a specific option from that select box, I want my text area background to change, in a different cell.
- I have given the text area's an ID so that this can be made possible.
I currently can use this:
<select onChange="updateColor(this.options[this.selectedIndex].value);" name="sunday combo" id="Suncombo2">
<option value= " " selected="selected">Please Select</option>
<option value="FFFFCC">light yellow
<option value="CCFFFF">light blue
<option value="CCFFCC">light green
<option value="CCCCCC">gray
<option value="FFFFFF">white'
Javascript:
<SCRIPT LANGUAGE="JavaScript">
function updateColor(color){
var myCell = document.getElementById('2ndInputSun');
myCell.style.background = "#"+color;
}
HTML:
<tr class="5row">
<td class="2ndInputMon"><textarea></textarea></td>
<td class="2ndInputTues"><textarea></textarea></td>
<td class="2ndInputWed"><textarea></textarea></td>
<td class="2ndInputThurs"><textarea></textarea></td>
<td class="2ndInputFri"><textarea></textarea></td>
<td class="2ndInputSat"><textarea></textarea></td>
<td class="2ndInputSun"><textarea></textarea></td>
However, when I insert all this, I get no change in colour from the text area.