I'm trying to implement a feature where the field value changes to green when "OK" is selected and red when "NOK" is chosen. I have written the following JavaScript code but it's not working as expected - the colors change before clicking submit, but after submission, the field color reverts back to 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"; }
};
});