Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Here is a simple example of two user text inputs, which "instantly" calculate the answer based on the called JavaScript function (The functions are also included). In addition, this code provides the option to also use a button (it is currently commented out). Hope this helps!</p> <p><strong>HTML:</strong> </p> <pre><code>&lt;body&gt; &lt;div id="form-main"&gt; &lt;div id="form-div"&gt; &lt;form class="form" id="form1" method="post"&gt; &lt;p class="celcius"&gt;&lt;h2 style="color:#FFF"&gt;Input:&lt;/h2&gt; &lt;input name="celsius" type="text" class="feedback-input" placeholder="Temperature (Celsius)" onkeyup="Conversion()" id="celsius" /&gt; &lt;/p&gt; &lt;hr&gt; &lt;h2 style="color:#FFF"&gt;Result:&lt;/h2&gt; &lt;p class="fahrenheit"&gt; &lt;input name="fahrenheit" type="text" class="feedback-input" id="fahrenheit" onkeyup="Conversion2()" placeholder="Temperature (Fahrenheit)" /&gt; &lt;/p&gt; &lt;!-- &lt;div class="submit"&gt; &lt;input type="button" value="CONVERT" id="button-blue" onClick="Conversion()"/&gt; &lt;div class="ease"&gt;&lt;/div&gt; &lt;/div&gt; --&gt; &lt;/form&gt; &lt;/div&gt; &lt;/body&gt; </code></pre> <p><strong>JavaScript:</strong></p> <pre><code>function Conversion() { var tempCels = parseFloat(document.getElementById('celsius').value); tempFarh =(tempCels)*(1.8)+(32); document.getElementById('fahrenheit').value= tempFarh; } function Conversion2() { var tempFarh = parseFloat(document.getElementById('fahrenheit').value); tempCels =(tempFarh - 32)/(1.8); document.getElementById('celsius').value= tempCels; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload