Hallo,
ich habe hier ein Script, welches einen Preis * X multipliziert. Das Problem: Es funktioniert nur bis 7, bei 8-9 wird gar nichts berechnet, 10 ganz falsch. Ich hoffe, mir kann jemand dabei helfen:
ich habe hier ein Script, welches einen Preis * X multipliziert. Das Problem: Es funktioniert nur bis 7, bei 8-9 wird gar nichts berechnet, 10 ganz falsch. Ich hoffe, mir kann jemand dabei helfen:
Code:
function summe() {
var s=0;
for (var i=1;i<2;i++) {
preis = document.getElementById("preis"+i).firstChild.data.replace("€","");
preis = preis.replace(",",".");
s+=(parseFloat(preis)*parseInt("0"+document.getElementById("a"+i).value));
}
document.getElementById('price').value=data="Preis: "+s.toFixed(2).replace(".",",")+" €";
}
</script>
<form>
<p class="artikel" style="width:100px;" id="preis1">2 €</p>
<p class="artikel" style="width:100px;"><input type="text" name="1" value="0" id="a1" style="width:40px;" onkeyup="summe()" /></p>
<input type="text" name="price" value=" " id="price" class="price" />
</form>