I have a form:
var total = parseInt($("#txtsuma").val());
function sumar(valor) {
total += valor;
//document.frmcalificar.total.value = total;
$("#lblsuma").text(total);
$("#txtsuma").val(total);
//document.frmcalificar.lblsuma.value = total;
}
function restar(valor) {
total -= valor;
$("#lblsuma").text(total);
$("#txtsuma").val(total);
}
<script
src="https://code.jquery.com/jquery-3.3.1.min.js"
integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
crossorigin="anonymous"></script>
<form id="frmcalificar" name="calificar">
<p>
<fieldset id="fieldset">
Referencia 1:
<input type="checkbox" name="ref1" id="ref1" value="10" onClick="if (this.checked) sumar(10); else restar(10)">10<br>
Referencia 2:</td>
<input type="checkbox" name="ref2" id="ref2"value="10" onClick="if (this.checked) sumar(10); else restar(10)">10
</fieldset>
</p>
<p>
<fieldset id="fieldset">
<legend>Experiencia</legend>
<input type="radio" class="optexp" name="optexp" id="optexp1" value="30" >Mayor de 10 Años (30 puntos)<br>
<input type="radio" class="optexp" name="optexp" id="optexp2" value="15" >Entre 1 y 10 Años (15 puntos)<br>
<input type="radio" class="optexp" name="optexp" id="optexp3" value="4" >Menor de 1 Años (4 puntos)
<input type="text" name="txtanteriorexp" id="txtanteriorexp" value="0">
</fieldset>
</p>
<label id="lblsuma" name = "lblsuma" style="font-size:14px; color:red"></label><b>
</form>
The interaction with the checkbox works perfectly, but I have not managed to make the script so that it can be added or subtracted according to what they are selecting in the radios . Can you give me a hand with this please.