Javascript Temperature Calculator

Javascript Temperature calculator is used to convert from fahrenheit to celsius and also convert from celsius to fahrenheit.Its mainly used for temperature conversion. Enter the degree to textbox,select the option from combobox and then find out the temperature.

Features

  • Enter the degree value to the textbox,select the option from combobox either fahrenheit or celsius.
  • Calculate and then produce the result with two decimal places.
  • This is free javascript calculator.
  • Copy the code from given textarea and use this calculator.

Preview

Enter the degree to the Textbox and select option from combobox then
calculate the temperature from fahrenheit to celsius and vice versa.


Enter the degree
Equal Value ©H

Downloads

Javascript Code


<!-- Script by hscripts.com -->
<!-- More scripts @www.hscripts.com -->
<script type="text/javascript">
function apply()
{
var a=frm.myoption.value;
if(a=="Fahrenheit")
{
var val=frm.txt.value;
var tf=parseInt(val);
var tc=(5/9)*(tf-32);
var res=Math.round(tc*Math.pow(10,2))/Math.pow(10,2);
frm.txt1.value=res+" C";
}
else
{
var val=frm.txt.value;
var tc=parseInt(val);
var tf=((9/5)*tc)+32;
var res1=Math.round(tf*Math.pow(10,2))/Math.pow(10,2);
frm.txt1.value=res1+" F";
} }
</script><!-- Script by hscripts.com -->

HTML Code


<form name="frm">
<table style="border:solid green 1px">
<tr><td>Enter the degree</td>
<td><input type=text name="txt" size=12"></td>
<td><select name="myoption">
<option name="Faren" value="Fahrenheit">F</option>
<option name="Cels" value="Celsius">C</option>
</select></td>
<td><input type="button" value="Calculate" onclick="apply()"></td></tr>
<tr><td>Equal Value</td>
<td><input type=text name="txt1" size="12" READONLY></td><td></td>
<td align=right>&copy<a href="https://www.hscripts.com" style="color:#3D366F;text-decoration:none;cursor:pointer;font-size:13px">hscripts.com</a></td></tr>
</table>
</form>

  • Release Date - 07-04-2008
  • Get free version without ©copyright link for just $10/-
  • For customization of this script or any script development, mail to support@hscripts.com

Usage

  • Copy the javascript code into the head part of your HTML page.
  • Create a HTML form using the above HTML code.
  • Here, the function "chkdecimals()" is called to give the value with two decimalplaces. The function "apply()" is called to calculate from fahrenheit to celsius and vice versa.
  • Copy the code into your page and use this calculator.

License

Related Scripts

Free Javascript Scripts


Ask Questions

Ask Question