/* write a function tha sum the choice of checkbox controls */ function sumChecked() { var sum = 0; var checkboxes = document.getElementsByTagName('input'); for (var i = 0; i < checkboxes.length; i++) { if (checkboxes[i].type == 'checkbox' && checkboxes[i].checked) { sum += parseInt(checkboxes[i].value); } } return sum; }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter