I got a input like this with a numbered value
<input type="radio" id="ja" name="upprepas" value="0">
<input type="radio" id="ja" name="bekanta" value="2">
But i also have like 10 other inputs, I want to count all of the inputed values. So I tried this:
var select = document.querySelector('input[name="upprepas"]:checked');
console.log(select.value);
var selecto = document.querySelector('input[name="bekanta"]:checked');
console.log(selecto.value);
var selector = select.value + selecto.value;
console.log(selector.value);
But selector is always undefined, why is that? I thought that it maybe was a string and not an integer so I tried putting parseInt before select.value but it didn't work.
document.querySelectorcould returnnullif its not found or checked which will throwconst total = +(select?.value || 0) + +(selecto?.value || 0)