Mas edit javascript


Is there a quicker way to mas edit java in forms, i have 5 forms each with 150 fields where I have to add

function sc_check_4_onchange()
{
var type = document.getElementsByName(‘check_4’)[0].value;

if(type == ‘Good’){
document.getElementById(‘select2-id_sc_field_check_4-container’).style.background=’#90ee90’;
}
else if(type == ‘Fair’){
document.getElementById(‘select2-id_sc_field_check_4-container’).style.background=’#FFFF00’;
}else if(type == ‘Poor’){
document.getElementById(‘select2-id_sc_field_check_4-container’).style.background=’#ffcccb’;
}else{
document.getElementById(‘select2-id_sc_field_check_4-container’).style.background=‘white’;
}
console.log(type);
}
function sc_check_72_onchange()
{
var type = document.getElementsByName(‘check_72’)[0].value;

if(type == ‘Compliant’){
document.getElementById(‘select2-id_sc_field_check_72-container’).style.background=’#90ee90’;
}
else if(type == ‘Non-Compliant’){
document.getElementById(‘select2-id_sc_field_check_72-container’).style.background=’#ffcccb’;
}else{
document.getElementById(‘select2-id_sc_field_check_72-container’).style.background=‘white’;
}
console.log(type);

}
And by clicking add java for each field will take forever