Newbie78
05-02-2006, 02:52 AM
Can someone please help me with this code of mine??? :confused:
Can't seem to round the sum to two decimal places of this code below:
document.Formular.Total.value =(wert1*1)+(wert2*1)
It actually works with the first bit of the code:
var k = (Math.round(temp * 20) / 20).toString();
k += (k.indexOf('.') == -1)? '.00' : '00';
return k.substring(0, k.indexOf('.') + 3);
return k;
Please help me....Thanks! :rolleyes:
See full code below:
<SCRIPT language=JavaScript>
<!--
function printit(){
window.print()
}
// -->
</SCRIPT>
<SCRIPT language=JavaScript>
<!--
function Wert(zahl1,zahl2) {
var temp=zahl1*zahl2*120/10000;
var k = (Math.round(temp * 20) / 20).toString();
k += (k.indexOf('.') == -1)? '.00' : '00';
return k.substring(0, k.indexOf('.') + 3);
return k;
}
function Berechne() {
var wert1 = Wert(document.Formular.Hoehe1.value,document.Formular.Breite1.value);
document.Formular.Ergebnisfeld1.value = wert1;
var wert2 = Wert(document.Formular.Hoehe2.value,document.Formular.Breite2.value);
document.Formular.Ergebnisfeld2.value = wert2;
document.Formular.Total.value =(wert1*1)+(wert2*1)
}
//-->
</SCRIPT>
Can't seem to round the sum to two decimal places of this code below:
document.Formular.Total.value =(wert1*1)+(wert2*1)
It actually works with the first bit of the code:
var k = (Math.round(temp * 20) / 20).toString();
k += (k.indexOf('.') == -1)? '.00' : '00';
return k.substring(0, k.indexOf('.') + 3);
return k;
Please help me....Thanks! :rolleyes:
See full code below:
<SCRIPT language=JavaScript>
<!--
function printit(){
window.print()
}
// -->
</SCRIPT>
<SCRIPT language=JavaScript>
<!--
function Wert(zahl1,zahl2) {
var temp=zahl1*zahl2*120/10000;
var k = (Math.round(temp * 20) / 20).toString();
k += (k.indexOf('.') == -1)? '.00' : '00';
return k.substring(0, k.indexOf('.') + 3);
return k;
}
function Berechne() {
var wert1 = Wert(document.Formular.Hoehe1.value,document.Formular.Breite1.value);
document.Formular.Ergebnisfeld1.value = wert1;
var wert2 = Wert(document.Formular.Hoehe2.value,document.Formular.Breite2.value);
document.Formular.Ergebnisfeld2.value = wert2;
document.Formular.Total.value =(wert1*1)+(wert2*1)
}
//-->
</SCRIPT>