I have an ajax code which is concepted from auto calculate the sum of input values with javascript. So I'd like to add more field to meet my needs. Then I added some inputs[checkbox] with given value in it. The idea is when the box is checked. Its value will be calculated to the process just like type in the input[text].
Here's the code :
<script language="javascript">
function AddInputs()
{
var total = 0;
var coll = document.getElementsByTagName("input")
for ( var i = 0; i<coll.length; i++)
{
var ele = coll[i];
total += parseInt(ele.value);
}
var Display = document.getElementById("Display");
Display.innerHTML = total;
}
</script>
Here's the form:
<input onkeyup="AddInputs()" />
<input onkeyup="AddInputs()" />
<input onkeyup="AddInputs()" />
<input type="checkbox" onkeyup="AddInputs()" value="100" />
<span id="Display"></span>
The problem is I can't make the checkbox to get calculated with those input boxes. Please suggest.