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>

One thought on “JavaScript parallel resistor circuit calculator”

  1. Greetings! I’ve been following your website for a very long time
    now and lastly got the courage to just offer you a shout out of Houston Texas!
    Just planned to let you know maintain the good work!

Leave a Reply

Your email address will not be published.

16 − two =