-4
I created a Javascript code with if Else to show on the screen the readjustment of a salary according to the category of worker selected in an input type ="radio". It turns out that only the first condition is calculated, regardless of the category choice by the user. Beforehand, very grateful for the help!
function calcular() {
var ca = document.getElementById("categoriaA");
var cb = document.getElementById("categoriaB");
var ck = document.getElementById("categoriaK");
var cl = document.getElementById("categoriaL");
var x = Number(salario.value);
var novoSalario;
var result = document.getElementById ("res");
result.value = novoSalario;
if(ca=true){
novoSalario = x + 100;
result.innerHTML = `Você passa a ganhar R$ ${novoSalario}`;
}else if(cb=true){
novoSalario = x + 150;
result.innerHTML = `Você passa a ganhar R$ ${novoSalario}`;
}else if(ck=true){
novoSalario = x + 200;
result.innerHTML = `Você passa a ganhar R$ ${novoSalario}`;
}else if(cl=true){
novoSalario = x + 250;
result.innerHTML = `Você passa a ganhar R$ ${novoSalario}`;
}else{
result.innerHTML = `Você precisa marcar a sua categoria`;
}
}