Phiên bản đầy đủ: jsB@nk » Tính toán » Tương đương » Đổi các đơn vị
URL: https://www.javascriptbank.com/unit-conversion-tables.html
Hiệu ứng có thể chuyển đổi một số các đơn vị như độ dài, thể tích, thời gian, vận tốc, khối lượng và năng lượng.
Phiên bản đầy đủ: jsB@nk » Tính toán » Tương đương » Đổi các đơn vị
URL: https://www.javascriptbank.com/unit-conversion-tables.html
<style type="text/css">body{background-color:white;font-size:10pt;color:black;font-family:sans-serif;}</style><!-- This script downloaded from www.JavaScriptBank.com Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->
<script language="javascript">function convert(index){var tmp=new Object();var d=document.f;tmp.name=units[index];tmp.t1=d[('t1'+tmp.name)].valueif(typeof parseInt(tmp.t1) != "number"){tmp.t1=1;d[('t1'+tmp.name)].value=1;}tmp.s1=d[('s1'+tmp.name)].selectedIndex;tmp.s2=d[('s2'+tmp.name)].selectedIndex;tmp.c1=eval(units[index]+'['+tmp.s1+'][1]');tmp.c2=eval(units[index]+'['+tmp.s2+'][1]');tmp.result=''+eval(tmp.t1+'*'+tmp.c1+'/'+tmp.c2);tmp.test=tmp.result.indexOf("e");if(tmp.test!=(-1)){tmp.test=tmp.result.substring(tmp.test,tmp.result.length);tmp.result=tmp.result.substring(0,10)+tmp.test}else{tmp.result=tmp.result.substring(0,13)}d[('t2'+tmp.name)].value=tmp.result;}var units=[ 'Length' , 'Area' , 'Volume' , 'Time' , 'Speed' , 'Mass' , 'Power' ];var Length=[['inch','.0254'],['foot','.3048'],['yard','.9144'],['mile','1609.344'],['nautical mile','1852'],['fathom','1.82880365761'], ['rod','5.02921005842'],['chain','20.1168402337'],['millimeter','.001'],['centimeter','.01'],['meter','1'],['kilometer','1000']]var Area=[['square meter','1'],['square centimeter','.0001'],['square yard','.83612736'],['square feet','.09290304'],['square inch','.00064516'],['square kilometer','1000000'],['acre','4046.87260987'],['square mile','2589988.11034']]var Volume=[['cubic meter','1'],['cubic centimeter','.000001'],['milliliter','.000001'],['liter','.001'],['cubic yard','.764554857984'],['cubic feet','.028316846592'],['cubic inch','.000016387064'],['gallons','.003785411784'],['quart','.000946352946'],['pints','.000473176473'],['fluid ounce','.0000295735295625'],['tablespoon','.000014786747813'],['teaspoon','.00000492892159375']]var Time=[['second','1'],['minute','60'],['hour','3600'],['day','86400'],['week','604800'],['year','31556925.9747']]var Speed=[['meters/sec','1'],['centimeters/sec','.01'],['feet/sec','.3048'],['kilometer/hour','.277777777778'],['miles/hour','.44704'],['knots','.514444444444'],['C','299792458']]var Mass=[['gram','1'],['kilogram','1000'],['ounce','28.349523125'],['pound','453.59237'],['slug','14593.9029372'],['ton','907184.74']]var Power=[['watts','1'],['horsePower','745.699871582']]</script><!-- This script downloaded from www.JavaScriptBank.com Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->
<form name="f"><table border="1" cellpadding="0" border="1"><tr><td><table cellspacing="0" cellpadding="10" border="0" bgcolor="ffedcf"><tr><td colspan="6" align="center"><h2>Unit Conversion tables</h2></td></tr><tr><td colspan="6" align="center"></td></tr><script language="javascript">var t='';for(i=0;i<units.length;i++){t+='<tr><td colspan="6"><hr width="100%" color="black"><font size="+2">'+units[i]+'</font></td></tr>';t+='<tr><td><input type="text" value="1" name="t1'+units[i]+'" size="5" onChange="convert('+i+')"></td><td>';t+='<select name="s1'+units[i]+'" onChange="convert('+i+')">';for(j=0;j<eval(units[i]+'.length');j++)t+='<option>'+eval(units[i]+'['+j+'][0]')+'</option>';t+='</select></td><td align="center">To</td><td>';t+='<select name="s2'+units[i]+'" onChange="convert('+i+')">';for(j=0;j<eval(units[i]+'.length');j++)t+='<option>'+eval(units[i]+'['+j+'][0]')+'</option>';t+='</select></td><td>=</td>';t+='<td><input type="text" readonly value="1" name="t2'+units[i]+'" size="14">';t+='</td></tr>';}document.write(t);</script></table></td></tr></table></form><!-- This script downloaded from www.JavaScriptBank.com Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->