I have a checkbox that at the time I select and search for the value in the type="text"
field, one of the fields is working perfectly plus the second field does not work.
function pega(){
var opcao = document.getElementById("opcao");
var numero1 = document.getElementById("number1").value;
var numero2 = document.getElementById("number2").value;
if (opcao.checked == true){
document.getElementById("total").innerHTML = numero1;
}
/*
if (opcao.checked == true){
document.getElementById("total").innerHTML = numero2;
}*/
}
<input type="checkbox" id="opcao" name="Pacote" value="primeira opcao" onclick ="pega()">
<input type="text" id="number1" />
<input type="checkbox" id="opcao" name="Pacote" value="primeira opcao" onclick ="pega()">
<input type="text" id="number2" />
<div id="total"></div>
My idea then is to calculate the two fields, but do I need to know if this way I'm going to do it?