i wanted to change the field value to green after selecting the value "OK" and red on "NOK" and so on. i have used the js code like the below code but it is not working like before clicking the sumbit button colours are changing but after it is submitted the field colour is again white.
$(document).ready(function(){
if(document.getElementById('janadd').value == 'NOK') {
document.getElementById('janadd').style.background-color = "red";
}
else if (document.getElementById('janadd').value == 'OK') {
document.getElementById('janadd').style.background-color = "green";
}
else if(document.getElementById('janadd').value == 'Partial'){
document.getElementById('janadd').style.background-color = "yellow"; }
};
});
Use
backgroundColor
and notbackground-color
, since this is not a valid property of thestyle
object.i use the jquery syntax: