I have a select box in a table 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. The table is dynamic so I do not know how many rows will be displayed. I need to do this for ALL rows in the table. It was suggested to use onload, but how can I go thru all the elements.
<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>
<TABLE>
<SELECT name="p_att_status" id="p_param1" onChange="getColor(this.id)">'
<OPTION value=.WHITE>Present
<OPTION value=*RED>Absent
</SELECT>
<TABLE>
When the page is displayed, I want to initially set the BG color of the select box depending on the value from the database. The table is dynamic so I do not know how many rows will be displayed. I need to do this for ALL rows in the table. It was suggested to use onload, but how can I go thru all the elements.
<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>
<TABLE>
<SELECT name="p_att_status" id="p_param1" onChange="getColor(this.id)">'
<OPTION value=.WHITE>Present
<OPTION value=*RED>Absent
</SELECT>
<TABLE>