somma += eval("document.forms[0].cod" + i + ".value");
o
somma += document.getElementByName("cod" + i).value;