Electron Logo Home

Home


Downloads

Downloads


Forums

Forums


Themes

Themes


Docs

Documents


License

License


About

About Us


PHP, MySQL and JavaScripts
    JavaScript
Others
    PHP
 Temperature Converter
HR
Code

<script type="text/javascript">
function convert(known) {
if (known == "Cel") {
var cel = document.theform.cel.value;
var far = (cel * 1.8) + 32;
far = Math.round(far * 1000) / 1000;
var kel = 273 + Number(cel);
kel = Math.round(kel * 1000) / 1000;
document.theform.far.value = far;
document.theform.kel.value = kel;
} else if (known == "Far") {
var far = document.theform.far.value;
var cel = (far - 32) / 1.8;
cel = Math.round(cel * 1000) / 1000;
var kel = cel + 273
kel = Math.round(kel * 1000) / 1000;
document.theform.cel.value = cel;
document.theform.kel.value = kel;
} else if (known == "Kel") {
var kel = document.theform.kel.value;
var cel = kel - 273;
cel = Math.round(cel * 1000) / 1000;
var far = (cel * 1.8) + 32;
far = Math.round(far * 1000) / 1000;
document.theform.cel.value = cel;
document.theform.far.value = far;
}
}
</script>

<form name='theform' action='javascript: void(0)'>
<p><b>Fahrenheit:</b> <input type='text' name='far' onChange="convert('Far')" /></p>
<p><b>Celcius:</b> <input type='text' name='cel' onChange="convert('Cel')" /></p>
<p><b>Kelvin:</b> <input type='text' name='kel' onChange="convert('Kel')" /></p>
<input type='submit' value='Convert!' />
</form>




Tell a friend
Powered By AEF 1.0.7 © 2008 Electron Inc.