Set background color for conditional text fields by click of button.
Hi,
I am new to apex, the scenario is when i click on a button i.e. Save, it shoulld compare 2 fields P1 and P2 which are text fields.
If the value of P1 is greaterthan P2 then the whole P1 text field background color should change to "Red" otherwise in any other condition the P1 field should be "Green" color.
In which section the color function should be called on the Save button?
On the page in the HTML Header section i have added the below code but the background color is not getting set.
<script type="text/javascript">
function fncChangeColor()
{
var num1 = $v('P1');
var num2 = $v('P2');
if ( num1 > num2 ) {
document.getElementById("P1").style.background = "RED";
}
else {
document.getElementById("P1").style.background = "GREEN";
}
}
</script>
Can any one help me in moving ahead with this scenario with a detailed information.
Thanks,
Priyanka.