Zurück zu Kiki

 

   Homepagetools

 

     Javascript - Scripte

 

         Mathematisches

Zwei-Zahlen-Rechner

 

 

 

Erste Zahl (X)

Zweite Zahl (Y)

  



Ergebnis

 


 

Script:

>>Das Script hier einfach kopieren und in einen Editor einfügen! Erst aus dem Editor weiterkopieren, z.B. in ein Frontpagedokument. Das >Style< und das>Script< kommt in den "head" der Webseite, das >Form< in den "body" der Seite an die Stelle, wo das Script stehen soll<<

<style type="text/css">
.button{color:white; background:black; 
width:70px; font-size:80%; font-weight:bold}
</style>
<script language="javascript">
<!--
//written by Kiki www.kikisweb.de


//Potenzieren x hoch y

function potenzen(ergebnis){

if( isNaN(document.rechner.x.value) || isNaN(document.rechner.y.value) )
document.rechner.ergebnis.value = "Ungültige Eingabe!"
else
document.rechner.ergebnis.value = Math.pow( document.rechner.x.value, document.rechner.y.value )

}

//Potenzieren y hoch x

function potenzen2(ergebnis){

if( isNaN(document.rechner.x.value) || isNaN(document.rechner.y.value) )
document.rechner.ergebnis.value = "Ungültige Eingabe!"
else
document.rechner.ergebnis.value = Math.pow( document.rechner.y.value, document.rechner.x.value )

}


// Subtrahieren x - y

function minus(ergebnis){

var a = document.rechner.x.value
var b = document.rechner.y.value
var zus= a - b

if( isNaN(document.rechner.x.value) || isNaN(document.rechner.y.value) )
document.rechner.ergebnis.value = "Ungültige Eingabe!"
else
document.rechner.ergebnis.value = ( zus )

}

//Subtrahieren y - x

function minus2(ergebnis){

var c = document.rechner.x.value
var d = document.rechner.y.value
var zus= d - c

if( isNaN(document.rechner.x.value) || isNaN(document.rechner.y.value) )
document.rechner.ergebnis.value = "Ungültige Eingabe!"
else
document.rechner.ergebnis.value = ( zus )

}



//Addieren 

function plus(ergebnis){

var a = Number(document.rechner.x.value)
var b = Number(document.rechner.y.value)
var zus= a + b

if( isNaN(document.rechner.x.value) || isNaN(document.rechner.y.value) )
document.rechner.ergebnis.value = "Ungültige Eingabe!"
else
document.rechner.ergebnis.value = ( zus )

}

//Multiplizieren

function multipl(ergebnis){

if( isNaN(document.rechner.x.value) || isNaN(document.rechner.y.value) )
document.rechner.ergebnis.value = "Ungültige Eingabe!"
else
document.rechner.ergebnis.value = ( document.rechner.x.value * document.rechner.y.value )

}

//Teilen x durch y

function xdurchy(ergebnis){

if( isNaN(document.rechner.x.value) || isNaN(document.rechner.y.value) )
document.rechner.ergebnis.value = "Ungültige Eingabe!"
else
document.rechner.ergebnis.value = ( document.rechner.x.value / document.rechner.y.value )

}

//Teilen y durch x

function ydurchx(ergebnis){

if( isNaN(document.rechner.x.value) || isNaN(document.rechner.y.value) )
document.rechner.ergebnis.value = "Ungültige Eingabe!"
else
document.rechner.ergebnis.value = ( document.rechner.y.value / document.rechner.x.value )

}

//Logarithmus von x

function logx(ergebnis){

if( isNaN(document.rechner.x.value) )
document.rechner.ergebnis.value = "Ungültige Eingabe!"
else
document.rechner.ergebnis.value = Math.log( document.rechner.x.value )

}

//Logarithmus von y

function logy(ergebnis){

if( isNaN(document.rechner.y.value) )
document.rechner.ergebnis.value = "Ungültige Eingabe!"
else
document.rechner.ergebnis.value = Math.log( document.rechner.y.value )

}

//Tangens von y

function tany(ergebnis){

if( isNaN(document.rechner.y.value) )
document.rechner.ergebnis.value = "Ungültige Eingabe!"
else
document.rechner.ergebnis.value = Math.tan( document.rechner.y.value )

}

//Tangens von x

function tanx(ergebnis){

if( isNaN(document.rechner.x.value) )
document.rechner.ergebnis.value = "Ungültige Eingabe!"
else
document.rechner.ergebnis.value = Math.tan( document.rechner.x.value )

}

// Sinus von x

function sinx(ergebnis){

if( isNaN(document.rechner.x.value) )
document.rechner.ergebnis.value = "Ungültige Eingabe!"
else
document.rechner.ergebnis.value = Math.sin( document.rechner.x.value )

}

//Sinus von y

function siny(ergebnis){

if( isNaN(document.rechner.y.value) )
document.rechner.ergebnis.value = "Ungültige Eingabe!"
else
document.rechner.ergebnis.value = Math.sin( document.rechner.y.value )

}


//Cosinus von x


function cosx(ergebnis){

if( isNaN(document.rechner.x.value) )
document.rechner.ergebnis.value = "Ungültige Eingabe!"
else
document.rechner.ergebnis.value = Math.cos( document.rechner.x.value )

}


//Cosinus von y

function cosy(ergebnis){

if( isNaN(document.rechner.y.value) )
document.rechner.ergebnis.value = "Ungültige Eingabe!"
else
document.rechner.ergebnis.value = Math.cos( document.rechner.y.value )

}


//-->
</script>


<FORM name="rechner">
<div align="center">
<table border="1" width="325" height="401" bgcolor="#000000" bordercolorlight="#C0C0C0" bordercolordark="#000000">
<tr>
<td width="310" height="19" colspan="4" bgcolor="#808080"></td>
</tr>

<tr>
<td width="310" height="41" colspan="4"><p align="center" style="margin-top: 0; margin-bottom: 0">
<font color="#FFFFFF" face="Verdana"><b>Erste Zahl (X)</b></font>
<p style="margin-top: 0; margin-bottom: 0" align="center">

<input type="text" name="x"> 

</p>

</td>
</tr>

<tr>
<td width="310" height="41" colspan="4">
<b><font face="Verdana" color="#FFFFFF"> 
<p align="center" style="margin-top: 0; margin-bottom: 0">Zweite Zahl (Y)<p style="margin-top: 0; margin-bottom: 0" align="center">

<input type="text" name="y"> </font></b> 

</p>
</td>
</tr>

<tr>
<td width="310" height="19" colspan="4" bgcolor="#808080"></td>
</tr>

<tr>
<td width="80" height="31" align="center" bgcolor="#000000" bordercolorlight="#C0C0C0" bordercolordark="#C0C0C0">
<input type="button" value="X + Y" onclick="plus()" class=button>
</td>

<td width="80" height="31" align="center" bgcolor="#000000" bordercolorlight="#C0C0C0" bordercolordark="#C0C0C0">
<p align="center"><font color="#FFFFFF" face="Verdana"><b>
<input type="button" value="X * Y" onclick="multipl()" class=button></b></font></p>
</td>


<td width="80" height="31" align="center" bgcolor="#000000" bordercolorlight="#C0C0C0" bordercolordark="#C0C0C0">
<input type="button" value="X : Y" onclick="xdurchy()" class=button>
</td>

<td width="81" height="31" align="center" bgcolor="#000000" bordercolorlight="#C0C0C0" bordercolordark="#C0C0C0"> 
<input type="button" value="Y : X" onclick="ydurchx()" class=button>
</td>

</tr>

<tr>
<td width="80" height="31" align="center" bgcolor="#000000" bordercolorlight="#C0C0C0" bordercolordark="#C0C0C0">

<input type="button" value="X - Y" onclick="minus()" class=button></center>
</td>

<td width="80" height="31" align="center" bgcolor="#000000" bordercolorlight="#C0C0C0" bordercolordark="#C0C0C0"><p align="center">
<input type="button" value="Y - X" onclick="minus2()" class=button></p>
</td>

<td width="80" height="31" align="center" bgcolor="#000000" bordercolorlight="#C0C0C0" bordercolordark="#C0C0C0">
<input type="button" value="X hoch Y" onclick="potenzen()" class=button>
</td>


<td align="center" width="81" height="31" bgcolor="#000000" bordercolorlight="#C0C0C0" bordercolordark="#C0C0C0">
<input type="button" value="Y hoch X" onclick="potenzen2()" class=button>
</tr>

<tr>
<td width="80" height="31" align="center" bgcolor="#000000" bordercolorlight="#C0C0C0" bordercolordark="#C0C0C0"><font color="#FFFFFF" face="Verdana"><b>
<input type="button" value="logX" onclick="logx()" class=button></b></font>
</td>

<td width="80" height="31" align="center" bgcolor="#000000" bordercolorlight="#C0C0C0" bordercolordark="#C0C0C0"><font color="#FFFFFF" face="Verdana"><b> 
<input type="button" value="logY" onclick="logy()" class=button></b></font>
</td>

<td width="80" height="31" align="center" bgcolor="#000000" bordercolorlight="#C0C0C0" bordercolordark="#C0C0C0">
<input type="button" value="sinX" onclick="sinx()" class=button>
</td>

<td width="81" height="31" align="center" bgcolor="#000000" bordercolorlight="#C0C0C0" bordercolordark="#C0C0C0">
<input type="button" value="sinY" onclick="siny()" class=button>
</td>
</tr>


<tr>
<td width="80" height="31" align="center" bgcolor="#000000" bordercolorlight="#C0C0C0" bordercolordark="#C0C0C0">
<input type="button" value="tanX" onclick="tanx()" class=button>
</td>

<td width="80" height="31" align="center" bgcolor="#000000" bordercolorlight="#C0C0C0" bordercolordark="#C0C0C0">
<input type="button" value="tanY" onclick="tany()" class=button>
</td>

<td align="center" width="80" height="31" bgcolor="#000000" bordercolorlight="#C0C0C0" bordercolordark="#C0C0C0">
<input type="button" value="cosX" onclick="cosx()" class=button>
</td>

<td width="81" height="31" align="center" bgcolor="#000000" bordercolorlight="#C0C0C0" bordercolordark="#C0C0C0">
<input type="button" value="cosY" onclick="cosy()" class=button>
</td>


</tr>

<tr>
<td width="310" height="19" colspan="4" bgcolor="#808080">&nbsp;&nbsp;</td>

</tr>

<tr>
<td width="310" colspan="4" height="77"><p align="center"><font color="#FFFFFF" face="Verdana"><b><br>
<input type="text" name="ergebnis"><br>Ergebnis<br></b></font>
</td>
</tr>

<tr>
<td width="310" colspan="4" height="19" bgcolor="#808080"></td>
</tr>
</table>
</center>
</div>
</FORM>

 

 

 

 


Nach oben

www.kikisweb.de