分享一款面积换算js脚本,输入数值后点击按钮可立即换算成其他单位的面积值,实用网页特效代码。
<html> <head> <meta http-equiv="content-Type" content="text/html;charset=gb2312"> <meta name="keywords" content="武鸣人网站,武鸣信息网,武鸣本地网,武鸣信息资源平台,减肥,健身,励志,励志语录,js特效,网页特效,www.wuming.ren"> <meta name="description" content="欢迎来到武鸣人信息资源平台,各种信息免费发布,资源共享合作共赢,分享互联网流行的励志语录经典短句,减肥健身健康小常识及打卡记录,收集各种js特效代码。"> <title>面积换算js脚本_武鸣人</title> <SCRIPT language=JScript type=text/JScript> <!-- function AREA_MEASURES() {//武鸣人网站https://www.wuming.ren 网站很好记住,wuming.ren(武鸣拼音.ren域名后缀) this.mSquare_kilometer = (1000 * 1000) this.mHectare = (100 * 100) this.mSquare_meter = 1 this.mAre = ((10000/15) * this.mSquare_meter) this.mSquare_decimeter = (0.1 * 0.1) this.mSquare_centimeter = (0.01 * 0.01) this.mSquare_millimeter = (0.001 * 0.001) this.engSquare_foot = (0.3048 * 0.3048) this.engSquare_yard = (3 * 3 * this.engSquare_foot) this.usSquare_rod = (16.5 *16.5 * this.engSquare_foot) this.engAcre = 160 * this.usSquare_rod this.engSquare_mile = (5280 *5280 * this.engSquare_foot) this.engSquare_inch = (this.engSquare_foot / (12 * 12)) }//武鸣人网站https://www.wuming.ren 网站很好记住,wuming.ren(武鸣拼音.ren域名后缀) var area_data = new AREA_MEASURES(); function checkNum(str) { for (var i=0; i<str.length; i++) { var ch = str.substring(i, i + 1) if (ch!="." && ch!="+" && ch!="-" && ch!="e" && ch!="E" && (ch < "0" || ch > "9")) { alert("请输入有效的数字"); return false; } } return true }//武鸣人网站https://www.wuming.ren 网站很好记住,wuming.ren(武鸣拼音.ren域名后缀) function normalize(what,digits) { var str=""+what; var pp=Math.max(str.lastIndexOf("+"),str.lastIndexOf("-")); var idot=str.indexOf("."); if (idot>=1) { var ee=(pp>0)?str.substring(pp-1,str.length):""; digits+=idot; if (digits>=str.length) return str; if (pp>0 && digits>=pp) digits-=pp; var c=eval(str.charAt(digits)); var ipos=digits-1; if (c>=5) { while (str.charAt(ipos)=="9") ipos--; if (str.charAt(ipos)==".") { var nc=eval(str.substring(0,idot))+1; if (nc==10 && ee.length>0) { nc=1; ee="e"+(eval(ee.substring(1,ee.length))+1); } return ""+nc+ee; } return str.substring(0,ipos)+(eval(str.charAt(ipos))+1)+ee; } else var ret=str.substring(0,digits)+ee; for (var i=0; i<ret.length; i++) if (ret.charAt(i)>"0" && ret.charAt(i)<="9") return ret; return str; } return str; }//武鸣人网站https://www.wuming.ren 网站很好记住,wuming.ren(武鸣拼音.ren域名后缀) function compute(obj,val,data) { if (obj[val].value) { var uval=0; uval = obj[val].value*data[val]; if( (uval >= 0) && (obj[val].value.indexOf("-") != -1) ) { uval = -uval; // *** Hack for Opera 4.0 2000-10-14 } for (var i in data) obj[i].value=normalize(uval/data[i],8); } } function resetValues(form,data) { for (var i in data) form[i].value=""; } function resetAll(form) {//武鸣人网站https://www.wuming.ren 网站很好记住,wuming.ren(武鸣拼音.ren域名后缀) resetValues(form,area_data); } //--> </SCRIPT> </head> <body> <a href="https://www.wuming.ren">武鸣人</a>,各种信息资源免费发布,分享励志语录经典短句,减肥健身常识,各种js特效代码。网站很好记住,wuming.ren(武鸣拼音.ren域名后缀)<hr> <!--欢迎来到武鸣人信息资源平台,各种信息免费发布,资源共享合作共赢,分享互联网流行的励志语录经典短句,减肥健身健康小常识及打卡记录,收集各种js特效代码。--> <script type="text/javascript" src="https://www.wuming.ren/ad/tc.js"></script> <script type="text/javascript" src="https://www.wuming.ren/ad/a.js"></script> <TABLE width="100%" border="0" cellPadding=0 cellSpacing=0 class="small"> <TBODY> <TR> <TD align="center" valign="top"> <FORM action=""> <br> <TABLE width="75%" align="center" cellPadding=4 cellSpacing=0 class="small"> <TBODY> <TR> <TD colspan="6"> 可实现平方公里(km<SUP>2</SUP>)、公顷(ha)、市亩、平方米(m<SUP>2</SUP>)、平方分米(dm<SUP>2</SUP>)、平方厘米(cm<SUP>2</SUP>)、平方毫米(mm<SUP>2</SUP>)、平方英里(sq mi)、英亩、平方竿(sq rd)、平方码(sq yd)、平方英尺(sq ft)、平方英寸(sq in)间的互转互换。</TD> </TR> <TR> <TD colspan="6"> </TD> </TR> <TR> <TD align=right noWrap>平方公里(km<SUP>2</SUP>)</TD> <TD align=left><INPUT name=mSquare_kilometer class="SmallInput" size=15></TD> <TD align=left><INPUT onclick="if (checkNum(mSquare_kilometer.value)) compute(this.form,mSquare_kilometer.name,area_data)" type=button value=换算 class='SmallButton' name=mSquare_kilometer_bt></TD> <TD align=right noWrap>公顷(ha)</TD> <TD align=left><INPUT name=mHectare class="SmallInput" size=15></TD> <TD align=left><INPUT onclick="if (checkNum(mHectare.value)) compute(this.form,mHectare.name,area_data)" type=button value=换算 class='SmallButton' name=mHectare_bt></TD> </TR> <TR> <TD align=right noWrap>市亩</TD> <TD align=left><INPUT name=mAre class="SmallInput" size=15></TD> <TD align=left><INPUT onclick="if (checkNum(mAre.value)) compute(this.form,mAre.name,area_data)" type=button value=换算 class='SmallButton' name=mAre_bt></TD> <TD align=right noWrap>平方米(m<SUP>2</SUP>)</TD> <TD align=left><INPUT name=mSquare_meter class="SmallInput" size=15></TD> <TD align=left><INPUT onclick="if (checkNum(mSquare_meter.value)) compute(this.form,mSquare_meter.name,area_data)" type=button value=换算 class='SmallButton' name=mSquare_meter_bt></TD> </TR> <TR> <TD align=right noWrap>平方分米(dm<SUP>2</SUP>)</TD> <TD align=left><INPUT name=mSquare_decimeter class="SmallInput" size=15></TD> <TD align=left><INPUT onclick="if (checkNum(mSquare_decimeter.value)) compute(this.form,mSquare_decimeter.name,area_data)" type=button value=换算 class='SmallButton' name=mSquare_decimeter_bt></TD> <TD align=right noWrap>平方厘米(cm<SUP>2</SUP>)</TD> <TD align=left><INPUT name=mSquare_centimeter class="SmallInput" size=15></TD> <TD align=left><INPUT onclick="if (checkNum(mSquare_centimeter.value)) compute(this.form,mSquare_centimeter.name,area_data)" type=button value=换算 class='SmallButton' name=mSquare_centimeter_bt></TD> </TR> <TR> <TD align=right noWrap>平方毫米(mm<SUP>2</SUP>)</TD> <TD align=left><INPUT name=mSquare_millimeter class="SmallInput" size=15></TD> <TD align=left><INPUT onclick="if (checkNum(mSquare_millimeter.value)) compute(this.form,mSquare_millimeter.name,area_data)" type=button value=换算 class='SmallButton' name=mSquare_millimeter_bt></TD> <TD align=right noWrap>平方英里(sq mi)</TD> <TD align=left><INPUT name=engSquare_mile class="SmallInput" size=15></TD> <TD align=left><INPUT onclick="if (checkNum(engSquare_mile.value)) compute(this.form,engSquare_mile.name,area_data)" type=button value=换算 class='SmallButton' name=engSquare_mile_bt></TD> </TR> <TR> <TD align=right noWrap>英亩</TD> <TD align=left><INPUT name=engAcre class="SmallInput" size=15></TD> <TD align=left><INPUT onclick="if (checkNum(engAcre.value)) compute(this.form,engAcre.name,area_data)" type=button value=换算 class='SmallButton' name=engAcre_bt></TD> <TD align=right noWrap>平方竿(sq rd)</TD> <TD align=left><INPUT name=usSquare_rod class="SmallInput" size=15></TD> <TD align=left><INPUT onclick="if (checkNum(usSquare_rod.value)) compute(this.form,usSquare_rod.name,area_data)" type=button value=换算 class='SmallButton' name=usSquare_rod_bt></TD> </TR> <TR> <TD align=right noWrap>平方码(sq yd)</TD> <TD align=left><INPUT name=engSquare_yard class="SmallInput" size=15></TD> <TD align=left><INPUT onclick="if (checkNum(engSquare_yard.value)) compute(this.form,engSquare_yard.name,area_data)" type=button value=换算 class='SmallButton' name=engSquare_yard_bt></TD> <TD align=right noWrap>平方英尺(sq ft)</TD> <TD align=left><INPUT name=engSquare_foot class="SmallInput" size=15></TD> <TD align=left><INPUT onclick="if (checkNum(engSquare_foot.value)) compute(this.form,engSquare_foot.name,area_data)" type=button value=换算 class='SmallButton' name=engSquare_foot_bt></TD> </TR> <TR> <TD align=right noWrap>平方英寸(sq in)</TD> <TD align=left><INPUT name=engSquare_inch class="SmallInput" size=15></TD> <TD align=left><INPUT onclick="if (checkNum(engSquare_inch.value)) compute(this.form,engSquare_inch.name,area_data)" type=button value=换算 class='SmallButton' name=engSquare_inch_bt></TD> <TD colSpan=3></TD> </TR> </TBODY> </TABLE> <br> <div align="center"> <INPUT onclick=resetAll(this.form) type=button value=数据重置 class='SmallButton' name=res7> </div> </FORM></TD> </TR> </TBODY> </TABLE> </body> </html>
本文来自武鸣人网站,转载请注明出处