Calculator JavaScript

This is a little example about a JavaScript Calculator, he could calculate some simple things another solution is to use eval.





JavaScript code:
var Wert = 0;
var OP = ":";
function CalcPlus ()
{
if(document.Eingabe.TB.value != ""&&OP!=":"){CalcErg();}
switch(OP)
{
case "+":
document.Eingabe.TB.value = 1*Wert+1*document.Eingabe.TB.value;document.Eingabe.TB.value="";OP=":";
break;
case "-":
document.Eingabe.TB.value = Wert-document.Eingabe.TB.value;document.Eingabe.TB.value="";OP=":";
break;
case "*":
document.Eingabe.TB.value = Wert*document.Eingabe.TB.value;document.Eingabe.TB.value="";OP=":";
break;
case "/":
document.Eingabe.TB.value = Wert/document.Eingabe.TB.value;document.Eingabe.TB.value="";OP=":";
break;
default:
Wert = document.Eingabe.TB.value;
document.Eingabe.TB.value="";
}
OP="+";
}
function CalcMinus ()
{
if(document.Eingabe.TB.value != ""&&OP!=":"){CalcErg();}
switch(OP)
{
case "+":
document.Eingabe.TB.value = 1*Wert+1*document.Eingabe.TB.value;document.Eingabe.TB.value="";OP=":";
break;
case "-":
document.Eingabe.TB.value = Wert-document.Eingabe.TB.value;document.Eingabe.TB.value="";OP=":";
break;
case "*":
document.Eingabe.TB.value = Wert*document.Eingabe.TB.value;document.Eingabe.TB.value="";OP=":";
break;
case "/":
document.Eingabe.TB.value = Wert/document.Eingabe.TB.value;document.Eingabe.TB.value="";OP=":";
break;
default:
Wert = document.Eingabe.TB.value;
document.Eingabe.TB.value="";
}
OP="-";
}
function CalcMal ()
{
if(document.Eingabe.TB.value != ""&&OP!=":"){CalcErg();}
switch(OP)
{
case "+":
document.Eingabe.TB.value = 1*Wert+1*document.Eingabe.TB.value;document.Eingabe.TB.value="";OP=":";
break;
case "-":
document.Eingabe.TB.value = Wert-document.Eingabe.TB.value;document.Eingabe.TB.value="";OP=":";
break;
case "*":
document.Eingabe.TB.value = Wert*document.Eingabe.TB.value;document.Eingabe.TB.value="";OP=":";
break;
case "/":
document.Eingabe.TB.value = Wert/document.Eingabe.TB.value;document.Eingabe.TB.value="";OP=":";
break;
default:
Wert = document.Eingabe.TB.value;
document.Eingabe.TB.value="";
}
OP="*";
}
function CalcDiv ()
{
if(document.Eingabe.TB.value != ""&&OP!=":"){CalcErg();}
switch(OP)
{
case "+":
document.Eingabe.TB.value = 1*Wert+1*document.Eingabe.TB.value;document.Eingabe.TB.value="";OP=":";
break;
case "-":
document.Eingabe.TB.value = Wert-document.Eingabe.TB.value;document.Eingabe.TB.value="";OP=":";
break;
case "*":
document.Eingabe.TB.value = Wert*document.Eingabe.TB.value;document.Eingabe.TB.value="";OP=":";
break;
case "/":
document.Eingabe.TB.value = Wert/document.Eingabe.TB.value;document.Eingabe.TB.value="";OP=":";
break;
default:
Wert = document.Eingabe.TB.value;
document.Eingabe.TB.value="";
}
OP="/";
}
function CalcErg ()
{
switch(OP)
{
case "+":
document.Eingabe.TB.value = 1*Wert+1*document.Eingabe.TB.value;
break;
case "-":
document.Eingabe.TB.value = Wert-document.Eingabe.TB.value;
break;
case "*":
document.Eingabe.TB.value = Wert*document.Eingabe.TB.value;
break;
case "/":
document.Eingabe.TB.value = Wert/document.Eingabe.TB.value;
break;
default:
document.Eingabe.TB.value=Wert;
}
OP=":";
Wert=document.Eingabe.TB.value;
}
function CalcClear ()
{
document.Eingabe.TB.value ="";OP=":";Wert=0;
}
  HTML code:
<form name="Eingabe">
<input type="text" name="TB">
<br>
<input type="button" onclick="javascript:CalcPlus()" value="+">
<input type="button" onclick="javascript:CalcMinus()" value="-">
<input type="button" onclick="javascript:CalcMal()" value="*">
<input type="button" onclick="javascript:CalcDiv()" value="/">
<input type="button" onclick="javascript:CalcErg()" value="=">
<br>
<input type="button" onclick="document.Eingabe.TB.value=Math.sqrt(document.Eingabe.TB.value)" value="sqrt">
<input type="button" onclick="document.Eingabe.TB.value=Math.sin(document.Eingabe.TB.value)" value="sin">
<input type="button" onclick="document.Eingabe.TB.value=Math.cos(document.Eingabe.TB.value)" value="cos">
<input type="button" onclick="document.Eingabe.TB.value=Math.tan(document.Eingabe.TB.value)" value="tan">
<br>
<input type="button" onclick="document.Eingabe.TB.value=1/document.Eingabe.TB.value" value="1/x">
<input type="button" onclick="document.Eingabe.TB.value=document.Eingabe.TB.value*1e3" value="x*1k">
<input type="button" onclick="document.Eingabe.TB.value=document.Eingabe.TB.value*1e-3" value="x*1m">
<input type="button" onclick="document.Eingabe.TB.value=Math.PI" value="Pi">
<br>
<input type="button" onclick="javascript:CalcClear()" value=" --< Clear >-- ">
<br>
</form>

HTML select on-change event JavaScript

This is an example how to get the index and selected text from a select in html:

Try it:

Code:
<script type="text/javascript">
function getOS(sel) {
    alert("Index: "+sel.selectedIndex+"  -  Value: "+sel.options[sel.selectedIndex].text);  
}
</script>

<select id="OS_SELECT" onchange="getOS(this)">
<option value="1">Linux</option>
<option value="2">Microsoft</option>
<option value="3">MAC OS X</option>
</select>

JavaScript series resistor circuit calculator

This is a JavaScript calculator how calculate with the ohm's law the voltage, ampere and the resistance.Its only an example but feel free to copy change or reuse this script. Try it:










UG-U1 U2
UG-U2 U1
U1+U2 UG
RG-R1 R2
RG-R2 R1
R1+R2 RG
(UG*R1)/RG U1
(UG*R2)/RG U2
UG/RG IG
U1/R1 IG
U2/R2 IG
(R1*U2)/R2 U1
(R2*U1)/R1 U2
(R2*U1)/U2 R1
(R1*U2)/U1 R2
UG/IG RG
UG/RG IG
RG*IG UG
Code:
<script>
function Berechne()
{
if(document.Eg.R1.value != "" && document.Eg.R2.value != "")//RG
{document.Eg.RG.value = 1*document.Eg.R1.value + document.Eg.R2.value*1;
document.getElementById("F0").style.backgroundColor = "#00FF00";
document.getElementById("FF0").style.backgroundColor = "#00FF00";
}else{
document.getElementById("F0").style.backgroundColor = "#FF0000";
document.getElementById("FF0").style.backgroundColor = "#FF0000";
}
if(document.Eg.RG.value != "" && document.Eg.R1.value != "")//R2
{document.Eg.R2.value = 1*document.Eg.RG.value - document.Eg.R1.value*1;
document.getElementById("F1").style.backgroundColor = "#00FF00";
document.getElementById("FF1").style.backgroundColor = "#00FF00";
}else{
document.getElementById("F1").style.backgroundColor = "#FF0000";
document.getElementById("FF1").style.backgroundColor = "#FF0000";
}
if(document.Eg.RG.value != "" && document.Eg.R2.value != "")//R1
{document.Eg.R1.value = 1*document.Eg.RG.value - document.Eg.R2.value*1;
document.getElementById("F2").style.backgroundColor = "#00FF00";
document.getElementById("FF2").style.backgroundColor = "#00FF00";
}else{
document.getElementById("F2").style.backgroundColor = "#FF0000";
document.getElementById("FF2").style.backgroundColor = "#FF0000";
}
if(document.Eg.U1.value != "" && document.Eg.U2.value != "")//UG
{document.Eg.UG.value = 1*document.Eg.U1.value + document.Eg.U2.value*1;
document.getElementById("F3").style.backgroundColor = "#00FF00";
document.getElementById("FF3").style.backgroundColor = "#00FF00";
}else{
document.getElementById("F3").style.backgroundColor = "#FF0000";
document.getElementById("FF3").style.backgroundColor = "#FF0000";
}
if(document.Eg.UG.value != "" && document.Eg.U1.value != "")//U2
{document.Eg.U2.value = 1*document.Eg.UG.value - document.Eg.U1.value*1;
document.getElementById("F4").style.backgroundColor = "#00FF00";
document.getElementById("FF4").style.backgroundColor = "#00FF00";
}else{
document.getElementById("F4").style.backgroundColor = "#FF0000";
document.getElementById("FF4").style.backgroundColor = "#FF0000";
}
if(document.Eg.UG.value != "" && document.Eg.U2.value != "")//U1
{document.Eg.U1.value = 1*document.Eg.UG.value - document.Eg.U2.value*1;
document.getElementById("F5").style.backgroundColor = "#00FF00";
document.getElementById("FF5").style.backgroundColor = "#00FF00";
}else{
document.getElementById("F5").style.backgroundColor = "#FF0000";
document.getElementById("FF5").style.backgroundColor = "#FF0000";
}
//end
if(document.Eg.R1.value != "" && document.Eg.R2.value != ""&& document.Eg.UG.value != "")//U1
{document.Eg.U1.value = (1*document.Eg.UG.value * document.Eg.R1.value*1)/(document.Eg.RG.value);
document.getElementById("F6").style.backgroundColor = "#00FF00";
document.getElementById("FF6").style.backgroundColor = "#00FF00";
}else{
document.getElementById("F6").style.backgroundColor = "#FF0000";
document.getElementById("FF6").style.backgroundColor = "#FF0000";
}
if(document.Eg.R1.value != "" && document.Eg.R2.value != ""&& document.Eg.UG.value != "")//U2
{document.Eg.U2.value = (1*document.Eg.UG.value * document.Eg.R2.value*1)/(document.Eg.RG.value);
document.getElementById("F7").style.backgroundColor = "#00FF00";
document.getElementById("FF7").style.backgroundColor = "#00FF00";
}else{
document.getElementById("F7").style.backgroundColor = "#FF0000";
document.getElementById("FF7").style.backgroundColor = "#FF0000";
}
if(document.Eg.UG.value != "" && document.Eg.RG.value != "")//IG
{document.Eg.IG.value = 1*document.Eg.UG.value / document.Eg.RG.value*1;
document.getElementById("F8").style.backgroundColor = "#00FF00";
document.getElementById("FF8").style.backgroundColor = "#00FF00";
}else{
document.getElementById("F8").style.backgroundColor = "#FF0000";
document.getElementById("FF8").style.backgroundColor = "#FF0000";
}
if(document.Eg.U1.value != "" && document.Eg.R1.value != "")//IG
{document.Eg.IG.value = 1*document.Eg.U1.value / document.Eg.R1.value*1;
document.getElementById("F9").style.backgroundColor = "#00FF00";
document.getElementById("FF9").style.backgroundColor = "#00FF00";
}else{
document.getElementById("F9").style.backgroundColor = "#FF0000";
document.getElementById("FF9").style.backgroundColor = "#FF0000";
}
if(document.Eg.U2.value != "" && document.Eg.R2.value != "")//IG
{document.Eg.IG.value = 1*document.Eg.U2.value / document.Eg.R2.value*1;
document.getElementById("F10").style.backgroundColor = "#00FF00";
document.getElementById("FF10").style.backgroundColor = "#00FF00";
}else{
document.getElementById("F10").style.backgroundColor = "#FF0000";
document.getElementById("FF10").style.backgroundColor = "#FF0000";
}
if(document.Eg.U1.value != "" && document.Eg.R1.value != ""&& document.Eg.R2.value != "")
{document.Eg.U2.value = (document.Eg.R2.value*document.Eg.U1.value)/document.Eg.R1.value;
document.getElementById("F11").style.backgroundColor = "#00FF00";
document.getElementById("FF11").style.backgroundColor = "#00FF00";
}else{
document.getElementById("F11").style.backgroundColor = "#FF0000";
document.getElementById("FF11").style.backgroundColor = "#FF0000";
}
if(document.Eg.U2.value != "" && document.Eg.R1.value != ""&& document.Eg.R2.value != "")
{document.Eg.U1.value = (document.Eg.R1.value * document.Eg.U2.value)/document.Eg.R2.value;
document.getElementById("F12").style.backgroundColor = "#00FF00";
document.getElementById("FF12").style.backgroundColor = "#00FF00";
}else{
document.getElementById("F12").style.backgroundColor = "#FF0000";
document.getElementById("FF12").style.backgroundColor = "#FF0000";
}
if(document.Eg.U1.value != "" && document.Eg.U2.value != ""&& document.Eg.R1.value != "")
{document.Eg.R2.value = (document.Eg.R1.value *document.Eg.U2.value)/document.Eg.U1.value;
document.getElementById("F14").style.backgroundColor = "#00FF00";
document.getElementById("FF14").style.backgroundColor = "#00FF00";
}else{
document.getElementById("F14").style.backgroundColor = "#FF0000";
document.getElementById("FF14").style.backgroundColor = "#FF0000";
}
if(document.Eg.U1.value != "" && document.Eg.U2.value != ""&& document.Eg.R2.value != "")
{document.Eg.R1.value = (document.Eg.R2.value*document.Eg.U1.value)/document.Eg.U2.value;
document.getElementById("F15").style.backgroundColor = "#00FF00";
document.getElementById("FF15").style.backgroundColor = "#00FF00";
}else{
document.getElementById("F15").style.backgroundColor = "#FF0000";
document.getElementById("FF15").style.backgroundColor = "#FF0000";
}
if(document.Eg.UG.value != "" && document.Eg.IG.value != "")
{document.Eg.RG.value=document.Eg.UG.value/document.Eg.IG.value;
document.getElementById("F16").style.backgroundColor = "#00FF00";
document.getElementById("FF16").style.backgroundColor = "#00FF00";
}else{
document.getElementById("F16").style.backgroundColor = "#FF0000";
document.getElementById("FF16").style.backgroundColor = "#FF0000";
}
if(document.Eg.UG.value != "" && document.Eg.RG.value != "")
{document.Eg.IG.value=document.Eg.UG.value/document.Eg.RG.value;
document.getElementById("F17").style.backgroundColor = "#00FF00";
document.getElementById("FF17").style.backgroundColor = "#00FF00";
}else{
document.getElementById("F17").style.backgroundColor = "#FF0000";
document.getElementById("FF17").style.backgroundColor = "#FF0000";
}
if(document.Eg.RG.value != "" && document.Eg.IG.value != "")
{document.Eg.UG.value=document.Eg.IG.value*document.Eg.RG.value;
document.getElementById("F18").style.backgroundColor = "#00FF00";
document.getElementById("FF18").style.backgroundColor = "#00FF00";
}else{
document.getElementById("F18").style.backgroundColor = "#FF0000";
document.getElementById("FF18").style.backgroundColor = "#FF0000";
}
}
</script>

<form name="Eg">
<br>
<label>R1 :</label>
<input type="text" name="R1">
<br>
<label>R2 :</label>
<input type="text" name="R2">
<br>
<label>RG :</label>
<input type="text" name="RG">
<br>
<label>U1 :</label>
<input type="text" name="U1">
<br>
<label>U2 :</label>
<input type="text" name="U2">
<br>
<label>UG :</label>
<input type="text" name="UG">
<br>
<label>IG :</label>
<input type="text" name="IG">
<br>
<input type="button" onclick="javascript:Berechne()" value="Berechne">
<br>
<br>
<table id="tom" width="20%" border="2">
<colgroup>
<col width="4*">
<col width="2*">
<col width="1*">
</colgroup>
<tbody>
<tr bgcolor="#E1E1E1" onmouseout="this.bgColor='#E1E1E1'" onmouseover="this.bgColor='#CCCCFF'">
<td id="F4">UG-U1</td>
<td id="FF4">U2</td>
</tr>
<tr bgcolor="#E1E1E1" onmouseout="this.bgColor='#E1E1E1'" onmouseover="this.bgColor='#CCCCFF'">
<td id="F5">UG-U2</td>
<td id="FF5">U1</td>
</tr>
<tr bgcolor="#E1E1E1" onmouseout="this.bgColor='#E1E1E1'" onmouseover="this.bgColor='#CCCCFF'">
<td id="F3">U1+U2</td>
<td id="FF3">UG</td>
</tr>
<tr bgcolor="#E1E1E1" onmouseout="this.bgColor='#E1E1E1'" onmouseover="this.bgColor='#CCCCFF'">
<td id="F0">RG-R1</td>
<td id="FF0">R2</td>
</tr>
<tr bgcolor="#E1E1E1" onmouseout="this.bgColor='#E1E1E1'" onmouseover="this.bgColor='#CCCCFF'">
<td id="F2">RG-R2</td>
<td id="FF2">R1</td>
</tr>
<tr bgcolor="#E1E1E1" onmouseout="this.bgColor='#E1E1E1'" onmouseover="this.bgColor='#CCCCFF'">
<td id="F1">R1+R2</td>
<td id="FF1">RG</td>
</tr>
<tr bgcolor="#E1E1E1" onmouseout="this.bgColor='#E1E1E1'" onmouseover="this.bgColor='#CCCCFF'">
<td id="F6">(UG*R1)/RG</td>
<td id="FF6">U1</td>
</tr>
<tr bgcolor="#E1E1E1" onmouseout="this.bgColor='#E1E1E1'" onmouseover="this.bgColor='#CCCCFF'">
<td id="F7">(UG*R2)/RG</td>
<td id="FF7">U2</td>
</tr>
<tr bgcolor="#E1E1E1" onmouseout="this.bgColor='#E1E1E1'" onmouseover="this.bgColor='#CCCCFF'">
<td id="F8">UG/RG</td>
<td id="FF8">IG</td>
</tr>
<tr bgcolor="#E1E1E1" onmouseout="this.bgColor='#E1E1E1'" onmouseover="this.bgColor='#CCCCFF'">
<td id="F9">U1/R1</td>
<td id="FF9">IG</td>
</tr>
<tr bgcolor="#E1E1E1" onmouseout="this.bgColor='#E1E1E1'" onmouseover="this.bgColor='#CCCCFF'">
<td id="F10">U2/R2</td>
<td id="FF10">IG</td>
</tr>
<tr bgcolor="#E1E1E1" onmouseout="this.bgColor='#E1E1E1'" onmouseover="this.bgColor='#CCCCFF'">
<td id="F12">(R1*U2)/R2</td>
<td id="FF12">U1</td>
</tr>
<tr bgcolor="#E1E1E1" onmouseout="this.bgColor='#E1E1E1'" onmouseover="this.bgColor='#CCCCFF'">
<td id="F11">(R2*U1)/R1</td>
<td id="FF11">U2</td>
</tr>
<tr bgcolor="#E1E1E1" onmouseout="this.bgColor='#E1E1E1'" onmouseover="this.bgColor='#CCCCFF'">
<td id="F15">(R2*U1)/U2</td>
<td id="FF15">R1</td>
</tr>
<tr bgcolor="#E1E1E1" onmouseout="this.bgColor='#E1E1E1'" onmouseover="this.bgColor='#CCCCFF'">
<td id="F14">(R1*U2)/U1</td>
<td id="FF14">R2</td>
</tr>
<tr bgcolor="#E1E1E1" onmouseout="this.bgColor='#E1E1E1'" onmouseover="this.bgColor='#CCCCFF'">
<td id="F16">UG/IG</td>
<td id="FF16">RG</td>
</tr>
<tr bgcolor="#E1E1E1" onmouseout="this.bgColor='#E1E1E1'" onmouseover="this.bgColor='#CCCCFF'">
<td id="F17">UG/RG</td>
<td id="FF17">IG</td>
</tr>
<tr bgcolor="#E1E1E1" onmouseout="this.bgColor='#E1E1E1'" onmouseover="this.bgColor='#CCCCFF'">
<td id="F18">RG*IG</td>
<td id="FF18">UG</td>
</tr>
</tbody>
</table>
</form>

JavaScript parallel resistor circuit calculator

This is a JavaScript calculator how calculate with the ohm's law the voltage, ampere and the resistance.Its only an example but feel free to copy change or reuse this script. Try it:










RG=1/(1/R1+1/R2)
R1=-1/(1/R2-1/RG)
R2=-1/(1/R1-1/RG)
I1=(I2*R1)/R2
I2=(I1*R2)/R1
R1=(I1*R2)/I2
R2=(I2*R1)/I1
I2=(IG/(R1+R2))*R1
I1=(IG/(R1+R2))*R2
Code:
<script>
function Berechne()
{
if(document.Eg.I1.value != "" && document.Eg.I2.value != "")
{document.Eg.IG.value = 1*document.Eg.I1.value + document.Eg.I2.value*1;}
if(document.Eg.IG.value != "" && document.Eg.I1.value != "")
{document.Eg.I2.value = 1*document.Eg.IG.value - document.Eg.I1.value*1;}
if(document.Eg.IG.value != "" && document.Eg.I2.value != "")
{document.Eg.I1.value = 1*document.Eg.IG.value - document.Eg.I2.value*1;}
if(document.Eg.R1.value != "" && document.Eg.R2.value != "")
{document.Eg.RG.value = 1/(1/document.Eg.R1.value + 1/document.Eg.R2.value);
document.getElementById("F1").style.backgroundColor = "#00FF00";
}else{document.getElementById("F1").style.backgroundColor = "#FF0000";}
if(document.Eg.R2.value != "" && document.Eg.RG.value != "")
{document.Eg.R1.value = -1/(1/document.Eg.R2.value-1/document.Eg.RG.value);
document.getElementById("F2").style.backgroundColor = "#00FF00";
}else{document.getElementById("F2").style.backgroundColor = "#FF0000";}
if(document.Eg.R1.value != "" && document.Eg.RG.value != "")
{document.Eg.R2.value = -1/((1/document.Eg.R1.value)-(1/document.Eg.RG.value));
document.getElementById("F3").style.backgroundColor = "#00FF00";
}else{document.getElementById("F3").style.backgroundColor = "#FF0000";}
if(document.Eg.I2.value != "" && document.Eg.R1.value != ""&& document.Eg.R2.value != "")
{document.Eg.I1.value = (document.Eg.I2.value*document.Eg.R1.value)/document.Eg.R2.value;
document.getElementById("F4").style.backgroundColor = "#00FF00";
}else{document.getElementById("F4").style.backgroundColor = "#FF0000";}
if(document.Eg.I1.value != "" && document.Eg.R1.value != ""&& document.Eg.R2.value != "")
{document.Eg.I2.value = (document.Eg.I1.value*document.Eg.R2.value)/document.Eg.R1.value;
document.getElementById("F5").style.backgroundColor = "#00FF00";
}else{document.getElementById("F5").style.backgroundColor = "#FF0000";}
if(document.Eg.I1.value != "" && document.Eg.I2.value != ""&& document.Eg.R2.value != "")
{document.Eg.R1.value = (document.Eg.I1.value*document.Eg.R2.value)/document.Eg.I2.value;
document.getElementById("F6").style.backgroundColor = "#00FF00";
}else{document.getElementById("F6").style.backgroundColor = "#FF0000";}
if(document.Eg.I1.value != "" && document.Eg.I2.value != ""&& document.Eg.R1.value != "")
{document.Eg.R2.value = (document.Eg.I2.value*document.Eg.R1.value)/document.Eg.I1.value;
document.getElementById("F7").style.backgroundColor = "#00FF00";
}else{document.getElementById("F7").style.backgroundColor = "#FF0000";}
if(document.Eg.RG.value != "" && document.Eg.UG.value != "")
{document.Eg.IG.value = document.Eg.UG.value/document.Eg.RG.value;
}
if(document.Eg.IG.value != "" && document.Eg.R1.value != "" && document.Eg.R2.value != "")
{document.Eg.I2.value = (document.Eg.IG.value/(document.Eg.R1.value*1+document.Eg.R2.value*1))*document.Eg.R1.value;
document.getElementById("F8").style.backgroundColor = "#00FF00";
}else{document.getElementById("F8").style.backgroundColor = "#FF0000";}
if(document.Eg.IG.value != "" && document.Eg.R2.value != "" && document.Eg.R2.value != "")
{document.Eg.I1.value = (document.Eg.IG.value/(document.Eg.R1.value*1+document.Eg.R2.value*1))*document.Eg.R2.value;
document.getElementById("F9").style.backgroundColor = "#00FF00";
}else{document.getElementById("F9").style.backgroundColor = "#FF0000";}
}
</script>

<form name="Eg">
<br>
<label>R1 :</label>
<input type="text" name="R1">
<br>
<label>R2 :</label>
<input type="text" name="R2">
<br>
<label>RG :</label>
<input type="text" name="RG">
<br>
<label>I1 :</label>
<input type="text" name="I1">
<br>
<label>I2 :</label>
<input type="text" name="I2">
<br>
<label>IG :</label>
<input type="text" name="IG">
<br>
<label>UG :</label>
<input type="text" name="UG">
<br>
<input type="button" onclick="javascript:Berechne()" value="Berechne">
<br>
<br>
<table id="tom" width="20%" border="2">
<colgroup>
<col width="4*">
<col width="2*">
<col width="1*">
</colgroup>
<tbody>
<tr bgcolor="#E1E1E1" onmouseout="this.bgColor='#E1E1E1'" onmouseover="this.bgColor='#CCCCFF'">
<td id="F1">RG=1/(1/R1+1/R2)</td>
</tr>
<tr bgcolor="#E1E1E1" onmouseout="this.bgColor='#E1E1E1'" onmouseover="this.bgColor='#CCCCFF'">
<td id="F2">R1=-1/(1/R2-1/RG)</td>
</tr>
<tr bgcolor="#E1E1E1" onmouseout="this.bgColor='#E1E1E1'" onmouseover="this.bgColor='#CCCCFF'">
<td id="F3">R2=-1/(1/R1-1/RG)</td>
</tr>
<tr bgcolor="#E1E1E1" onmouseout="this.bgColor='#E1E1E1'" onmouseover="this.bgColor='#CCCCFF'">
<td id="F4">I1=(I2*R1)/R2</td>
</tr>
<tr bgcolor="#E1E1E1" onmouseout="this.bgColor='#E1E1E1'" onmouseover="this.bgColor='#CCCCFF'">
<td id="F5">I2=(I1*R2)/R1</td>
</tr>
<tr bgcolor="#E1E1E1" onmouseout="this.bgColor='#E1E1E1'" onmouseover="this.bgColor='#CCCCFF'">
<td id="F6">R1=(I1*R2)/I2</td>
</tr>
<tr bgcolor="#E1E1E1" onmouseout="this.bgColor='#E1E1E1'" onmouseover="this.bgColor='#CCCCFF'">
<td id="F7">R2=(I2*R1)/I1</td>
</tr>
<tr bgcolor="#E1E1E1" onmouseout="this.bgColor='#E1E1E1'" onmouseover="this.bgColor='#CCCCFF'">
<td id="F8">I2=(IG/(R1+R2))*R1</td>
</tr>
<tr bgcolor="#E1E1E1" onmouseout="this.bgColor='#E1E1E1'" onmouseover="this.bgColor='#CCCCFF'">
<td id="F9">I1=(IG/(R1+R2))*R2</td>
</tr>
</tbody>
</table>
</form>

HTML store data in data tag

If you want to store some data in a tage you could use the data- tag. try it:

1


code:
<!DOCTYPE html>
<html>
<body>

<p id="test" data-old="1">1</p>

<button onclick="myFunction()">Try it</button>

<script>
function myFunction() {
    document.getElementById("test").setAttribute("data-old",document.getElementById("test").innerHTML); 
    document.getElementById("test").innerHTML = 2*document.getElementById("test").innerHTML;
   
}
</script>

</body>
</html>
 

HTML Mail to line break

If you want to make a line break in the mail body to you could use this:
%0D%0A
its just a line feed and carriage return. For white spaces you could use this:
%20
for more information look at RFC 2368   This is a little example:
<a href="mailto:paul.scheinast@yahoo.de?subject=criticism&body=Hello,%0D%0A%0D%0Ayour text.%0D%0A%0D%0Amfg%0D%0Auser">Mail to</a>
  Try it: Mail to  

for loop Benchmark

This is a Perl Benchmark about the for loop with fix range and with a post increment that's the fastest increment (Perl increment Benchmark):
#!/usr/bin/perl
use strict;
use warnings;
use Benchmark qw(:all) ;
 

cmpthese(-1, {
'pre'  => sub {for(my $a=0;$a<=10;++$a){print $a;} },
'fix'  => sub {for(1..10){print $_;} },
});
Our result:
pre 135196/s  -- -5% 
fix 141940/s  5%  --
We see that we always should choose the for loop with a fixed range its possible.

Perl increment Benchmark

This is a Perl Benchmark about post-increment,pre-increment and a normal increment:
#!/usr/bin/perl
use strict;
use warnings;
use Benchmark qw(:all) ;
 

cmpthese(-1, {
'pre'   => sub {for(my $a=0;$a<=10;++$a){print $a;} },
'post'  => sub {for(my $a=0;$a<=10;$a++){print $a;} },
'dev'   => sub {for(my $a=0;$a<=10;$a+=1){print $a;} },
});
This is our result:
dev  124842/s   --  -9% -16%  
post 136533/s   9%   --  -8%  
pre  149123/s  19%   9%   --
pre increment is the fastest because it have not to increment the value and return the old value.But the fastest is the fixed range, take a look at for loop Benchmark.The default is the slowest because it have to handle other steps.

Perl array pop, push, shift, unshift

This is a notice about the array manipulation in Perl, but you should try to avoid to manipulate if you just could iterate troth the array, this is much faster, for this look at Perl shift iterate Benchmark.   pop remove and return the last element of the array. push add an element to the end of the array. shift remove and return the first element of the array. unshift add an element to the start of the array.   Code example:
my @var = ("middle");

#to the start
unshift(@var,"start");
#to the end
push(@var,"end");

#print
print "@var".$/;
print "start:",shift @var,$/;
print "end:",pop @var,$/;
print "@var".$/;
  Prints this:
start middle end
start:start
end:end
middle

Perl shift iterate Benchmark

This little Perl Benchmark shows that its better to iterate through an array as to manipulate via shift.For more about shift look at Perl array pop, push, shift, unshift.
#!/usr/bin/perl
use strict;
use warnings;
use Benchmark qw(:all) ;

 
cmpthese(-1, {
'shift'   => sub {my @var = (1..4);print shift(@var); },
'iterate' => sub {my @var = (1..4);print $var[0]; },
});
We see its better to iterate as to shift from an array:
shift   1147836/s      --     -4%  
iterate 1191563/s      4%      --