<table id="myTable">
<tr>
<th><input type="checkbox">
<th><input>
</tr>
<tr>
<th><input type="checkbox">
<th><input>
</tr>
</table>
<button id="myButton">sum = 0</button>
<script>
window.onload = function () {
var myTable = document.getElementById('myTable');
var myButton = document.getElementById('myButton');
var rows = myTable.rows;
var len = rows.length;
var checkbox;
var inp;
var sum;
myButton.onclick = function () {
sum = 0;
for (var i = 0; i < len; i++) {
checkbox = rows[i].children[0].children[0];
inp = rows[i].children[1].children[0];
if (checkbox.checked == true && isNaN(parseFloat(inp.value)) != true) {
sum += parseFloat(inp.value);
}
}
myButton.innerHTML = 'sum = ' + sum;
}
}
</script>