I need to use the value of a select in an if, I currently have this:
Esse seria o HTML:
<p>Quantidade de vidas? </p>
<select>
<option value="vidas1" id="vidas">Mais 1000</option>
<option value="vidas2" id="vidas">Mais 5000</option>
<option value="vidas3" id="vidas">Menos 1000</option>
</select>
<p>Importancia ?</p>
<select>
<option value="marca1" id="marca">Pouco Importante</option>
<option value="marca2" id="marca">Importante</option>
</select>
<input type="button" id="resposta" value="Calcular"/>
<p>Resultado:<p> <span id="resultado"></span>
Having this, I use JS to get the value of what was selected in the select
Esse seria o JS:
window.onload = function(){
var btn = document.getElementById("resposta");
btn.addEventListener("click",function(){
var nomedoCliente = parseFloat(document.getElementById("nmCliente").value)
calcular(nomedoCliente);
},false);
function calcular(a){
var clienteNm = document.getElementById("nmCliente").value
var qtdeVidas = document.getElementById("vidas").value
var importanciaOp = document.getElementById("marca").value
if (qtdeVidas == "vidas1" && importanciaOp == "marca1" ) {
document.getElementById("resultado").innerHTML="<p> "+clienteNm+", identificamos que você se encontra no nivel 1</p>"
}
else {
document.getElementById("resultado").innerHTML="<p> "+clienteNm+"</p>"
}
However, no matter what value I put selected, it always goes into the first if where it says it is at level1, and I do not know what's going on.