Tach auch,
ich habe folgendes Problem. Rechner in JavaSript soll das Ergebnis auf zwei
Kommastellen auf- bzw. Abrunden.
Hat einer eine Lösung für das Problem ?
Hier ist das Script:
<script language="JavaScript">
<!--
function Eco()
{
var x = 0;
x = eval(window.document.Rechner.Display1.value);
window.document.Rechner.Display.value = x * 0.24;
}
function Hinzufuegen(Zeichen)
{
window.document.Rechner.Display1.value =
window.document.Rechner.Display1.value + Zeichen;
}
function Vario()
{
var x = 0;
x = eval(window.document.Rechner.Display1.value);
window.document.Rechner.Display.value = x;
if (eval(window.document.Rechner.Display1.value) < 2000 )
{
x = eval(window.document.Rechner.Display1.value);
window.document.Rechner.Display.value = x * 0.20;
}
if (eval(window.document.Rechner.Display1.value) >= 2000 &&
(window.document.Rechner.Display1.value) < 3000)
{
x = eval(window.document.Rechner.Display1.value);
window.document.Rechner.Display.value = x * 0.30;
.
. usw
.
if (eval(window.document.Rechner.Display1.value) >= 10000 )
{
x = eval(window.document.Rechner.Display1.value);
window.document.Rechner.Display.value = x * 0.23;
}
}
/ / - ></script>
<input name="Display1" size=20 maxlength=10 value="0"> // Eingabe der Zahl
<input name="Display" size=20 maxlength=7 value="0"> // Ergebnis
<input type=button value="Button2" onClick="Vario()" name="button2"> //
berechnen
<input type=button value=" Button " onClick="Eco()" name="button"> //
berechnen
<input type=reset value="löschen" name="reset">
Gruß
Eric