Hello,
i'm making this code and i m trying to create code that can count the checkboxes together.
for now i have writen this code : not important verbs are in my language so ignore that ..
i m looking for any ideas how can i change this code to be able to count both checkboxes for now i can only pick one and when i do both my reasults came wrong ... it counts only 1.
so i would be glad if anyone could help me with that.
so my question is how to rewrite the code to be able to count both checkboxes into the result. thanks { if there are more then 2 then ofc it have to count all of them.
}
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
"
http://www.w3.org/TR/html4/frameset.dtd">
<HTML>
<HEAD>
<TITLE>A simple frameset document</TITLE>
<script>
function myFunction() {
var a = document.getElementById("a").value;
var b = document.getElementById("b").value;
var e = document.getElementById("e").value;
var w = document.getElementById("w").value;
var typ = document.getElementsByName("typ");
var z = 0;
for (var i = 0; i < typ.length; i++) {
if (typ
.type === 'checkbox' && typ.checked) {
z = typ.value;
}
}
alert((a*1+e*1-w*1)*15/100-24840*1-b*1*11604- z);
}
</script>
</HEAD>
<body>
<h1>Dan z prijmu fyzickych osob</h1>
<form>
hruby prijem:<br>
<input type="text" name="a" id="a">
<br/>
uhrn pojist. zaplaceneho zamesttnavatelem za zamestnance:<br>
<input type="text" name="e" id="e">
<br/>
odecitatelne polozky slevy:<br>
<input type="text" name="w" id="w">
<br/>
manzelka manzel v domacnosti: <br>
<input type="checkbox" name="typ" id="q" value="10" >
<br/>
studium: <br>
<input type="checkbox" name="typ" id="x" value="50" >
<br/>
dite:<br>
<input type="text" name="b" id="b">
<br/>
</form>
<button onclick="myFunction()">Click me</button>
</body>
</html>