I have a select box that is dynamically getting its options from the database. I have created a function that changes the BG color of the select box when the option value is changed. This works fine.
When the page is displayed, I want to initially set the BG color of the select box depending on the value from the database. How can I do this?
<SCRIPT LANGUAGE="JavaScript">
function getColor(p_param_id) {
theSelect = document.getElementById(p_param_id)
theColor = theSelect.options[theSelect.selectedIndex].value
theSelect.style.backgroundColor = theColor.substr(1, theColor.length)
}
</SCRIPT>
<SELECT name="p_att_status" id="p_param1" onChange="getColor(this.id)">'
<OPTION value=.WHITE>Present
<OPTION value=*RED>Absent
</SELECT>
When the page is displayed, I want to initially set the BG color of the select box depending on the value from the database. How can I do this?
<SCRIPT LANGUAGE="JavaScript">
function getColor(p_param_id) {
theSelect = document.getElementById(p_param_id)
theColor = theSelect.options[theSelect.selectedIndex].value
theSelect.style.backgroundColor = theColor.substr(1, theColor.length)
}
</SCRIPT>
<SELECT name="p_att_status" id="p_param1" onChange="getColor(this.id)">'
<OPTION value=.WHITE>Present
<OPTION value=*RED>Absent
</SELECT>