Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript">
function summe() {
var s=0;
for (var i=1;i<4;i++) {
a=parseFloat(document.getElementById("preis"+i).value);
c=parseFloat("0"+document.getElementById("a"+i).value)
c=c.replace(/,/,".");
c=parseFloat(c);
b=a*c;
s+=b;
document.getElementById("summe"+i).value=b.toFixed(2);
}
document.getElementById("summe").value=s.toFixed(2);
document.getElementById("MWST").value=s*0.19.toFixed(2);
document.getElementById("BRUTTO").value=s*1.19.toFixed(2);
}
</script>
</head>
<body>
<table>
<caption>
Preisrechner
</caption>
<tr>
<th>Ware</th>
<th>Einzelpreis</th>
<th>Anzahl</th>
</tr>
<tr>
<td>Mantel</td>
<td><input type="text" id="preis1" value="0" size="5" onchange="summe()">
€</td>
<td><input type="text" id="a1" value="0" size="5" onchange="summe()"></td>
<td colspan="2"><input type="text" id="summe1" size="5" disabled>
€</td>
</tr>
<tr>
<td>Degen</td>
<td><input type="text" id="preis2" value="0" size="5" onchange="summe()">
€</td>
<td><input type="text" id="a2" value="0" size="5" onchange="summe()"></td>
<td colspan="2"><input type="text" id="summe2" size="5"disabled>
€</td>
</tr>
<tr>
<td>Colt</td>
<td><input type="text" id="preis3" value="0" size="5" onchange="summe()">
€</td>
<td><input type="text" id="a3" value="0" size="5" onchange="summe()"></td>
<td colspan="2"><input type="text" id="summe3" size="5"disabled>
€</td>
</tr>
<tr>
<th>Summe</th>
<td colspan="2"><input type="text" id="summe" size="5" disabled>
€</td></tr>
<tr>
<th>MWST</th>
<td colspan="2"><input type="text" id="MWST" size="5" disabled>
€</td>
</tr>
<th>Brutto</th>
<td colspan="2"><input type="text" id="BRUTTO" size="5" disabled>
€</td>
</tr>
</table>
</body>
</html>
Egal was und wie ich es mache, sobald ersetzt werden soll bleiben die JS Felder unberechnet-. Selbst wenn ich mit Alert teste was C für einen Wert passiert GARNICHTS.
Was mache ich falsch?