How to change the background colors of a choice list?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-06-2015 01:07 AM
Hi Experts,
I tried with the below script to add the colors to the choice list.
g_form.clearOptions('u_risk_level');
var x = document.getElementById("u_deliverable.u_risk_level");
var option1 = document.createElement("option");
option1.text = "Green";
option1.name = "Green";
option1.value = "1";
option1.style.backgroundColor = '#32CD32';
option1.style.color = '#32CD32';
x.add(option1);
var option2 = document.createElement("option");
option2.text = "Red";
option2.name = "Red";
option2.value = "1";
option2.style.backgroundColor = 'Red';
option2.style.color = 'Red';
x.add(option2);
However once i select the color, it is showing the default white color instead of green. Please assist.
Thank you.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-06-2015 01:13 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-06-2015 01:58 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-06-2015 02:46 AM
This is a example from HTML that I had used previously.. Makes use of css to do logic.
<html>
<head>
<style>
.redText {
background-color:#F00;
}
.greenText {
background-color:#0F0;
}
.blueText {
background-color:#00F;
}
</style>
<body>
<select
onchange="this.className=this.options[this.selectedIndex].className"
class="greenText">
<option class="greenText" value="green" >Green</option>
<option class="redText" value="red" >Red</option>
<option class="blueText" value="blue" >Blue</option>
</select>
</body>
</html>

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-06-2015 05:37 AM
This has been fixed with 2 onload client script and 1 onchnage client script. I will share the script soon. Thank you.