These scripts are a part of our HTML tutorial for beginners, and as such may contain more complete information than you need - please be tolerant if on occasion we "shoot below your knowledge level."
POPPA's Temperature Converter:
CHANGE ONE, THEN CLICK OUTSIDE ITS BOX
TO CALCULATE THE REMAINING THREE
Farenheit: Centigrade:
Rankine: Kelvin:

This JavaScript converter will recalculate remaining values if any one is entered. Temperatures relative to absolute zero are reflected in the second line as °Rankine (F) and °Kelvin (C) - instructions are provided for their exclusion if unwanted.

Useful HTML and Script are shown in bold, and may be simply copied in whole or part from your browser page - highlight with your mouse and Edit_Copy, then paste into your HTML document so it looks as shown. Required entries are in bold red.


1. The Script: (below)
NOTE: The black tags above and below the red script (showing the usual Head, Title, and Script open/close) must also be present in your document. No matter how many you use, scripts normally go between the <SCRIPT>...</SCRIPT> tags at the top of your document.

If you add several scripts, be aware that you may not have duplicate names for Forms or for Script functions in any one document. If there is conflict, choose the simplest and rename. To be on the safe side, ensure that variable names in your scripts are different from one script to the next.


(Everything from this line DOWN must appear in your document.)

The green lines marked "// -R- " are explanations to help understanding
of the script functions, and may be removed if desired.

<HEAD>
<TITLE>....title...</TITLE>
<SCRIPT language="JavaScript">
<!-- Hide JavaScript From Java-Impaired Browsers

//Poppa's Temperature Converter
//   -- PoppaJohn - 5/31/99 --  http://primeshop.com
function Fent( ){document.tempcon.C.value=Math.round(5/9*(document.tempcon.F.value-32)*100)/100}
function Cent( ){document.tempcon.F.value=Math.round(((.9999796*document.tempcon.C.value*9/5)+32)*100)/100}
// -R- The next four lines calculate absolute temp values in °Rankine (F) and °Kelvin (C).
// -R- They may be removed if absolute temps are not desired.
function Rent( ){document.tempcon.F.value=Math.round((1*document.tempcon.R.value-459.7)*100)/100}
function Kent( ){document.tempcon.C.value=Math.round((1*document.tempcon.K.value-273.2)*100)/100}
function absR( ){document.tempcon.R.value=Math.round(((1*document.tempcon.F.value)+459.7)*100)/100}
function absK( ){document.tempcon.K.value=Math.round(((1*document.tempcon.C.value)+273.2)*100)/100}
// END Poppa's Temperature Converter
// End Hiding -->
</SCRIPT>
</HEAD>
(Everything from this line UP must appear in your document.)

The odd-looking factor".9999796" corrects for a minute error in the common temperature conversion factors - its effect improves accuracy at near-absolute-zero temps.





All content © JPinc 1999