Hola, pjcaro.
 
A veces me resulta más fácil hacer un código nuevo que intentar cambiar otro. Aquí tienes esto, espero que te ayude: 
 Código HTML:
 <html>
<head>
<script>
var num=0;
function aceptar() {
	num=document.getElementById('numero').value;
	frm=document.forms[0];
	for(i=0;i<num;i++) {
		txt=document.createTextNode('Artículo '+i);
		frm.appendChild(txt);
		inp=document.createElement('input');
		inp.id='ar'+i;
		inp.value='0';
		inp.onkeyup=function() {
			var tot=0;
			for(i=0;i<num;i++)
				tot+=parseInt(document.getElementById('ar'+i).value);
			document.getElementById('total').value=tot;
		}
		frm.appendChild(inp);
		frm.appendChild(document.createElement('br'));
	}
}
</script>
</head>
<body>
<form>
Nº Artículos: <input type="text" id="numero" />
<input type="button" value="Aceptar" onclick="aceptar()" />
<br />
Total: <input type="text" id="total" /><br />
</form>
</body>
</html>  Saludos, 
