JavaScript Ohm’s law calculator

This is the Ohm's law calculator in Javascript:


Javscript:
function Berechne(){
//allgemein
if(document.Eg.R.value != "" && document.Eg.U.value != "")
{document.Eg.I.value = document.Eg.U.value / document.Eg.R.value;}
if(document.Eg.I.value != "" && document.Eg.U.value != "")
{document.Eg.R.value = document.Eg.U.value / document.Eg.I.value;}
if(document.Eg.I.value != "" && document.Eg.R.value != "")
{document.Eg.U.value = document.Eg.R.value * document.Eg.I.value;}
if(document.Eg.I.value != "" && document.Eg.U.value != "")
{document.Eg.P.value = document.Eg.U.value * document.Eg.I.value;}
//P-Formeln
if(document.Eg.U.value != "" && document.Eg.R.value != "")
{document.Eg.P.value = (document.Eg.U.value*document.Eg.U.value) / document.Eg.R.value;}
if(document.Eg.I.value != "" && document.Eg.R.value != "")
{document.Eg.P.value = (document.Eg.I.value*document.Eg.I.value) * document.Eg.R.value;}
//I-Formeln
if(document.Eg.P.value != "" && document.Eg.U.value != "")
{document.Eg.I.value = document.Eg.P.value / document.Eg.U.value;}
if(document.Eg.P.value != "" && document.Eg.R.value != "")
{document.Eg.I.value = Math.sqrt(document.Eg.P.value / document.Eg.R.value);}
//R-Formeln
if(document.Eg.P.value != "" && document.Eg.U.value != "")
{document.Eg.R.value = (document.Eg.U.value*document.Eg.U.value) / document.Eg.P.value;}
if(document.Eg.I.value != "" && document.Eg.P.value != "")
{document.Eg.R.value = document.Eg.P.value / (document.Eg.I.value*document.Eg.I.value);}
//U-Formeln
if(document.Eg.I.value != "" && document.Eg.P.value != "")
{document.Eg.U.value = document.Eg.P.value / document.Eg.I.value;}
if(document.Eg.P.value != "" && document.Eg.R.value != "")
{document.Eg.U.value = Math.sqrt(document.Eg.P.value * document.Eg.R.value);}
}
And the HTML:
<form name="Eg"><label>R (Ohm) :</label>
<input name="R" type="text" />
<label>U (V) :</label>
<input name="U" type="text" />
<label>I (A) :</label>
<input name="I" type="text" />
<label>P (W) :</label>
<br>
<input name="P" type="text" /><input type="button" value="Berechne" />

2 thoughts on “JavaScript Ohm’s law calculator”

  1. A person essentially help to make critically articles I might state.
    This is the first time I frequented your website page and up to
    now? I surprised with the analysis you made to make this actual post
    amazing. Great activity!

  2. Howdy I am so happy I found your website, I really found you by mistake, while I was browsing on Google for something else, Regardless I am here now and would just like to say kudos for a
    tremendous post and a all round enjoyable blog (I also love the
    theme/design), I don’t have time to browse it all
    at the moment but I have bookmarked it and also added your
    RSS feeds, so when I have time I will be back to read a great
    deal more, Please do keep up the great work.

Leave a Reply

Your email address will not be published.

4 × 4 =