I have a table of input type=text fields and I want to set the bgColor of each field onChange as the user enters values. For example when someone types a positive number into NUM01 below, I want function CC to set the background color of the text field to green, and if they enter a negative number I want the background to change to red. I have tried modeling this on DOM, eg. oBj.bgColor = "red" but no joy. How should I do this? Can it be done in both IE and NN?
<script language="JavaScript"> // code sample
<!--
function CC(oBj) { // Change the BGcolor of the Input Type=Text field (need help with this)
objVal = oBj.value;
if (objVal > 0) oBj.bgColor = "green" // Green +ve
else if (objVal < 0) oBj.bgColor = "red" // Red -ve
else oBj.bgColor = "white"; // white for 0
}
//-->
</script>
<!-- snip -->
<FORM METHOD="POST" ACTION=" ... "><table><tr>
<td><INPUT TYPE=TEXT NAME="NUM01" onChange="CC(this)"></td>
<td><INPUT TYPE=TEXT NAME="NUM02" onChange="CC(this)"></td>
<td><INPUT TYPE=TEXT NAME="NUM03" onChange="CC(this)"></td>
<!-- snip -->
</tr>
</table>
<script language="JavaScript"> // code sample
<!--
function CC(oBj) { // Change the BGcolor of the Input Type=Text field (need help with this)
objVal = oBj.value;
if (objVal > 0) oBj.bgColor = "green" // Green +ve
else if (objVal < 0) oBj.bgColor = "red" // Red -ve
else oBj.bgColor = "white"; // white for 0
}
//-->
</script>
<!-- snip -->
<FORM METHOD="POST" ACTION=" ... "><table><tr>
<td><INPUT TYPE=TEXT NAME="NUM01" onChange="CC(this)"></td>
<td><INPUT TYPE=TEXT NAME="NUM02" onChange="CC(this)"></td>
<td><INPUT TYPE=TEXT NAME="NUM03" onChange="CC(this)"></td>
<!-- snip -->
</tr>
</table>