Ciao,
ho fatto un po' fatica a capire bene come sia strutturata precisamente la tua tabella, ti propongo perciò questa versione alternativa che dovrebbe funzionare

<script>
function calcola(){
var numero_prodotti = document.getElementById("numero_prodotti").value;
var totale = 0;
for(i=1; i<=numero_prodotti; i++){
var parziale = document.getElementById("p"+i).value*document.getE lementById("q"+i).value;
document.getElementById("t"+i).value = parziale
totale+= parziale;
}
document.getElementById("totale").innerHTML = totale+"€"
}
</script>
<form name="tabella">
<input type="hidden" id="numero_prodotti" value="3">
<table>
<tr>
<th>Nome prodotto</th>
<th>Prezzo unitario</th>
<th>Quantità</th>
<th>Totale</th>
</tr>
<tr>
<td>Prodotto 1</td>
<td><input type="text" readonly="yes" value="500" id="p1">€</td>
<td><input type="text" id="q1" value="1"></td>
<td><input type="text" readonly="yes" id="t1" value="500">€</td>
</tr>
<tr>
<td>Prodotto 2</td>
<td><input type="text" readonly="yes" value="500" id="p2">€</td>
<td><input type="text" id="q2" value="2"></td>
<td><input type="text" readonly="yes" id="t2" value="1000">€</td>
</tr>
<tr>
<td>Prodotto 3</td>
<td><input type="text" readonly="yes" value="250" id="p3">€</td>
<td><input type="text" id="q3" value="3"></td>
<td><input type="text" readonly="yes" id="t3" value="750">€</td>
</tr>
<tr>
<td colspan="4" align="center"><input type="button" onClick="calcola()" value="ricalcola il totale"></td>
</tr>
<tr>
<th colspan="3" align="right">Totale:</th>
<td id="totale">2250€</td>
</tr>
</table>
</form>

La struttura con i dati che vedi dovrebbero essere riempiti la prima volta con qualche linguaggio lato server e poi verranno completamente gestiti da js.