<script> function sum(){ var sum=0; var elems = document.getElementsByName('itog'); for (var i=0; i<elems.length; i++){ var n4 = elems[i].value; sum+=Number(n4); } document.getElementById('S1').value=sum; } </script>