Why my javascript code didn't work? This output value is NaN
.
for example my checkbox html code like this
<input type="checkbox" name="gejala" class="form-check-input checkbox-1x" id="GJ01" value="1">
<input type="checkbox" name="gejala" class="form-check-input checkbox-1x" id="GJ02" value="1">
<input type="checkbox" name="gejala" class="form-check-input checkbox-1x" id="GJ03" value="1">
<h5 id="probabilitas"></h5>
and want show this total value probability with js code like on my comment like this :
//----my array RULE--//
let AI = ["GJ01","GJ02","GJ03"];
for (var checkbox of markedCheckbox) {
if(checkbox.checked){
if(AI.includes(checkbox.id)){
console.log("Flu Burung");
document.getElementById("kesimpulan").hidden=false;
document.getElementById("PE01").hidden=false;
document.getElementById("Solusi01").hidden=false;
//myBugs code
for (var checkbox of markedCheckbox){
if(AI.includes(checkbox.value)){
y+=parseInt(checkbox.value);
}
}
probabilitas = document.getElementById("probabilitas");
probabilitas.innerHTML = (probabilitas.innerHTML.slice(0, -1) + y / 10 ) * 100;
} else if {
}
}
}
question from:
https://stackoverflow.com/questions/65859947/how-to-get-value-from-checkbox-checked-using-javascript 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…