Change colour of Select tag onChange()

Hi,

i have a select box as below.

<select onChange=“document…”>
<option value=“New”>New</option>
<option value=“Old”>Old</option>
</select>

onChange it filters the results by either New/Old. What i would like to do is to change the colour of the select box to show that an option has been selected. I.E after i select New the results are filtered and the select box changes colour.

Is this possible?

This will do what you want:

<select onChange="this.style.background='#FFFF00';">
<option value="New">New</option>
<option value="Old">Old</option>
</select>

I tested this in IE8 and Chrome and it worked to change the color whenever the value changes. Change the color value to whatever you want the color to be. You could also put this into a JavaScript function and reuse for several inputs on a form. If you have any questions let me know.

–Travis