体积和容积换算js脚本代码

7个月前 (05-10 10:01)阅读回复0
大陆
大陆
  • 管理员
  • 发消息
  • 注册排名1
  • 经验值5294
  • 级别管理员
  • 主题1058
  • 回复2
楼主

体积容积换算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 VOL_MEASURES()
{//武鸣人网站https://www.wuming.ren 网站很好记住,wuming.ren(武鸣拼音.ren域名后缀)
  this.mCubic_meter = 1000
  this.mHectoliter = 100
  this.mDekaliter = 10
  this.mLiter = 1
  this.mDeciliter = 0.1
  this.mCentiliter = 0.01
  this.mMilliliter = 0.001
  this.mCubic_millimeter = 0.000001
  this.mcTable_spoon= 0.015
  this.mcTea_spoon= 0.005
  this.uscCubic_inch = 0.016387064
  this.uscAcre_foot = 43560 * 1728 * this.uscCubic_inch
  this.uscCubic_yard = 27 * 1728 * this.uscCubic_inch
  this.uscCubic_foot = 1728 * this.uscCubic_inch
  this.uslGallon = 231 * this.uscCubic_inch
  this.uslBarrel = 42 * this.uslGallon
  this.uslQuart =  this.uslGallon / 4
  this.uslPint =  this.uslGallon / 8
  this.uslGill =  this.uslGallon / 32
  this.uslFluid_ounce = this.uslGallon / 128
  this.uslFluid_dram =  this.uslGallon / 1024
  this.uslMinim = this.uslFluid_ounce / 61440
  this.usdBarrel = 7056 * this.uscCubic_inch
  this.usdBushel = 2150.42 * this.uscCubic_inch
  this.usdPeck = this.usdBushel / 4
  this.usdQuart = this.usdBushel / 32
  this.usdPint = this.usdBushel / 64
  this.uscCup = 8 * this.uslFluid_ounce
  this.uscTable_spoon = this.uslFluid_ounce / 2
  this.uscTea_spoon = this.uslFluid_ounce / 6
  this.briGallon = 4.54609
  this.briBarrel = 36 * this.briGallon
  this.briBushel = 8  * this.briGallon
  this.briPint = this.briGallon / 8
  this.briFluid_ounce = this.briGallon / 160
}//武鸣人网站https://www.wuming.ren 网站很好记住,wuming.ren(武鸣拼音.ren域名后缀)
var vol_data = new VOL_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)
{
  resetValues(form,vol_data);
}//武鸣人网站https://www.wuming.ren 网站很好记住,wuming.ren(武鸣拼音.ren域名后缀)
</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"><BR>
          <FORM action="">
            <TABLE width="75%" cellPadding=4 cellSpacing=0 class="small">
              <TBODY>
                <TR align="left">
                  <TD colSpan=6>  可实现立方米(Cubic meter)、公石(hectoliter)、十升(dekaliter)、立方分米(Cubic dm)、升(liter)、分升(deciliter)、厘升(centiliter)、立方厘米(Cubic cm)、毫升(milliliter)、立方毫米(Cubic millimeter)、桶(Barrel)、蒲式耳(Bushel)、配克(Peck)、夸脱(Quart)、品脱(Pint)、加仑(Gallon)、盎司(Ounce)、打兰(dram)、量滴(Minim)、立方码(Cubic yard)、立方英尺(Cubic foot)、立方英寸(Cubic inch)间的互转互换。</TD>
                </TR>
                <TR align="center">
                  <TD
                              colSpan=6><B>                  公   制</B>
                  <HR SIZE=1></TD>
                </TR>
                <TR>
                  <TD noWrap align=right>立方米(m<SUP>3</SUP>)</TD>
                  <TD align=left><INPUT size=12 name=mCubic_meter class="SmallInput"></TD>
                  <TD align=left><INPUT onclick="if (checkNum(mCubic_meter.value)) compute(this.form,mCubic_meter.name,vol_data)" type=button value=换算  class=朙SmallButton朙  name=mCubic_meter_bt></TD>
                  <TD noWrap align=right>公石(hl)</TD>
                  <TD align=left><INPUT size=12 name=mHectoliter class="SmallInput"></TD>
                  <TD align=left><INPUT onclick="if (checkNum(mHectoliter.value)) compute(this.form,mHectoliter.name,vol_data)" type=button value=换算  class=朙SmallButton朙  name=mHectoliter_bt></TD>
                </TR>
                <TR>
                  <TD noWrap align=right>十升(dal)</TD>
                  <TD align=left><INPUT size=12 name=mDekaliter class="SmallInput"></TD>
                  <TD align=left><INPUT onclick="if (checkNum(mDekaliter.value)) compute(this.form,mDekaliter.name,vol_data)" type=button value=换算  class=朙SmallButton朙  name=mDekaliter_bt></TD>
                  <TD noWrap align=right>立方分米(dm<SUP>3</SUP>)=升(l)</TD>
                  <TD align=left><INPUT size=12 name=mLiter class="SmallInput"></TD>
                  <TD align=left><INPUT onclick="if (checkNum(mLiter.value)) compute(this.form,mLiter.name,vol_data)" type=button value=换算  class=朙SmallButton朙  name=mLiter_bt></TD>
                </TR>
                <TR>
                  <TD noWrap align=right>分升(dl)</TD>
                  <TD align=left><INPUT size=12 name=mDeciliter class="SmallInput"></TD>
                  <TD align=left><INPUT onclick="if (checkNum(mDeciliter.value)) compute(this.form,mDeciliter.name,vol_data)" type=button value=换算  class=朙SmallButton朙  name=mDeciliter_bt></TD>
                  <TD noWrap align=right>厘升(cl)</TD>
                  <TD align=left><INPUT size=12 name=mCentiliter class="SmallInput"></TD>
                  <TD align=left><INPUT onclick="if (checkNum(mCentiliter.value)) compute(this.form,mCentiliter.name,vol_data)" type=button value=换算  class=朙SmallButton朙  name=mCentiliter_bt></TD>
                </TR>
                <TR>
                  <TD noWrap
                            align=right>立方厘米(cm<SUP>3</SUP>)=毫升(ml)</TD>
                  <TD align=left><INPUT size=12 name=mMilliliter class="SmallInput"></TD>
                  <TD align=left><INPUT onclick="if (checkNum(mMilliliter.value)) compute(this.form,mMilliliter.name,vol_data)" type=button value=换算  class=朙SmallButton朙  name=mMilliliter_bt></TD>
                  <TD noWrap align=right>立方毫米(mm<SUP>3</SUP>)</TD>
                  <TD align=left><INPUT size=12
                              name=mCubic_millimeter class="SmallInput"></TD>
                  <TD align=left><INPUT onclick="if (checkNum(mCubic_millimeter.value)) compute(this.form,mCubic_millimeter.name,vol_data)" type=button value=换算  class=朙SmallButton朙  name=mCubic_millimeter_bt></TD>
                </TR>
                <TR align="center">
                  <TD colSpan=6><B><br>
                  美制干量</B>
                    <HR SIZE=1>
                  </TD>
                </TR>
                <TR>
                  <TD noWrap align=right>桶</TD>
                  <TD align=left><INPUT size=12 name=usdBarrel class="SmallInput"></TD>
                  <TD align=left><INPUT onclick="if (checkNum(usdBarrel.value)) compute(this.form,usdBarrel.name,vol_data)" type=button value=换算  class=朙SmallButton朙  name=usdBarrel_bt></TD>
                  <TD noWrap align=right>蒲式耳(bu)</TD>
                  <TD align=left><INPUT size=12 name=usdBushel class="SmallInput"></TD>
                  <TD align=left><INPUT onclick="if (checkNum(usdBushel.value)) compute(this.form,usdBushel.name,vol_data)" type=button value=换算  class=朙SmallButton朙  name=usdBushel_bt></TD>
                </TR>
                <TR>
                  <TD noWrap align=right>配克(pk)</TD>
                  <TD align=left><INPUT size=12 name=usdPeck class="SmallInput"></TD>
                  <TD align=left><INPUT onclick="if (checkNum(usdPeck.value)) compute(this.form,usdPeck.name,vol_data)" type=button value=换算  class=朙SmallButton朙  name=usdPeck_bt></TD>
                  <TD noWrap align=right>夸脱(qt)</TD>
                  <TD align=left><INPUT size=12 name=usdQuart class="SmallInput"></TD>
                  <TD align=left><INPUT onclick="if (checkNum(usdQuart.value)) compute(this.form,usdQuart.name,vol_data)" type=button value=换算  class=朙SmallButton朙  name=usdQuart_bt></TD>
                </TR>
                <TR>
                  <TD noWrap align=right>品脱(pt)</TD>
                  <TD align=left><INPUT size=12 name=usdPint class="SmallInput"></TD>
                  <TD align=left><INPUT onclick="if (checkNum(usdPint.value)) compute(this.form,usdPint.name,vol_data)" type=button value=换算  class=朙SmallButton朙  name=usdPint_bt></TD>
                  <TD colSpan=3></TD>
                </TR>
                <TR align="center">
                  <TD colSpan=6><B><br>
                  英制液量和干量</B>
                    <HR SIZE=1>
                  </TD>
                </TR>
                <TR>
                  <TD noWrap align=right>桶</TD>
                  <TD align=left><INPUT size=12 name=briBarrel class="SmallInput"></TD>
                  <TD align=left><INPUT onclick="if (checkNum(briBarrel.value)) compute(this.form,briBarrel.name,vol_data)" type=button value=换算  class=朙SmallButton朙  name=briBarrel_bt></TD>
                  <TD noWrap align=right>蒲式耳</TD>
                  <TD align=left><INPUT size=12 name=briBushel class="SmallInput"></TD>
                  <TD align=left><INPUT onclick="if (checkNum(briBushel.value)) compute(this.form,briBushel.name,vol_data)" type=button value=换算  class=朙SmallButton朙  name=briBushel_bt></TD>
                </TR>
                <TR>
                  <TD noWrap align=right>加仑(bal)</TD>
                  <TD align=left><INPUT size=12 name=briGallon class="SmallInput"></TD>
                  <TD align=left><INPUT onclick="if (checkNum(briGallon.value)) compute(this.form,briGallon.name,vol_data)" type=button value=换算 class=朙SmallButton朙 name=briGallon_bt></TD>
                  <TD noWrap align=right>品脱(pt)</TD>
                  <TD align=left><INPUT size=12 name=briPint class="SmallInput"></TD>
                  <TD align=left><INPUT onclick="if (checkNum(briPint.value)) compute(this.form,briPint.name,vol_data)" type=button value=换算  class=朙SmallButton朙  name=briPint_bt></TD>
                </TR>
                <TR>
                  <TD noWrap align=right>液量盎司(fl oz)</TD>
                  <TD align=left><INPUT size=12
                            name=briFluid_ounce  class="SmallInput"></TD>
                  <TD align=left><INPUT onclick="if (checkNum(briFluid_ounce.value)) compute(this.form,briFluid_ounce.name,vol_data)" type=button value=换算  class=朙SmallButton朙  name=briFluid_ounce_bt></TD>
                  <TD colSpan=3></TD>
                </TR>
                <TR align="center">
                  <TD colSpan=6><B><br>
                  公制烹调制式</B>
                    <HR SIZE=1>
                  </TD>
                </TR>
                <TR>
                  <TD noWrap align=right>汤勺(Table spoon)</TD>
                  <TD align=left><INPUT size=12
                            name=mcTable_spoon  class="SmallInput"></TD>
                  <TD align=left><INPUT onclick="if (checkNum(mcTable_spoon.value)) compute(this.form,mcTable_spoon.name,vol_data)" type=button value=换算  class=朙SmallButton朙  name=mcTable_spoon_bt></TD>
                  <TD noWrap align=right>调羹(Tea spoon)</TD>
                  <TD align=left><INPUT size=12 name=mcTea_spoon class="SmallInput"></TD>
                  <TD align=left><INPUT onclick="if (checkNum(mcTea_spoon.value)) compute(this.form,mcTea_spoon.name,vol_data)" type=button value=换算  class=朙SmallButton朙  name=mcTea_spoon_bt></TD>
                </TR>
                <TR align="center">
                  <TD colSpan=6><B><br>
                  美制烹调制式</B>
                    <HR SIZE=1>
                  </TD>
                <TR>
                  <TD noWrap align=right>汤勺(Tbs)</TD>
                  <TD align=left><INPUT size=12
                            name=uscTable_spoon  class="SmallInput"></TD>
                  <TD align=left><INPUT onclick="if (checkNum(uscTable_spoon.value)) compute(this.form,uscTable_spoon.name,vol_data)" type=button value=换算  class=朙SmallButton朙  name=uscTable_spoon_bt></TD>
                  <TD noWrap align=right>调羹(tsp)</TD>
                  <TD align=left><INPUT size=12 name=uscTea_spoon class="SmallInput"></TD>
                  <TD align=left><INPUT onclick="if (checkNum(uscTea_spoon.value)) compute(this.form,uscTea_spoon.name,vol_data)" type=button value=换算  class=朙SmallButton朙  name=uscTea_spoon_bt></TD>
                </TR>
                <TR>
                  <TD noWrap align=right>杯(fl oz)</TD>
                  <TD align=left><INPUT size=12 name=uscCup  class="SmallInput"></TD>
                  <TD align=left><INPUT onclick="if (checkNum(uscCup.value)) compute(this.form,uscCup.name,vol_data)" type=button value=换算  class=朙SmallButton朙  name=uscCup_bt></TD>
                  <TD colSpan=3></TD>
                </TR>
                <TR align="center">
                  <TD colSpan=6><B><br>
                  美制液量</B>
                    <HR SIZE=1>
                  </TD>
                </TR>
                <TR>
                  <TD noWrap align=right>桶[42加仑]</TD>
                  <TD align=left><INPUT size=12 name=uslBarrel class="SmallInput"></TD>
                  <TD align=left><INPUT onclick="if (checkNum(uslBarrel.value)) compute(this.form,uslBarrel.name,vol_data)" type=button value=换算  class=朙SmallButton朙  name=uslBarrel_bt></TD>
                  <TD noWrap align=right>加仑(gal)</TD>
                  <TD align=left><INPUT size=12 name=uslGallon class="SmallInput"></TD>
                  <TD align=left><INPUT onclick="if (checkNum(uslGallon.value)) compute(this.form,uslGallon.name,vol_data)" type=button value=换算  class=朙SmallButton朙  name=uslGallon_spoon_bt></TD>
                </TR>
                <TR>
                  <TD noWrap align=right>夸脱(qt)</TD>
                  <TD align=left><INPUT size=12 name=uslQuart class="SmallInput"></TD>
                  <TD align=left><INPUT onclick="if (checkNum(uslQuart.value)) compute(this.form,uslQuart.name,vol_data)" type=button value=换算  class=朙SmallButton朙  name=uslQuart_bt></TD>
                  <TD noWrap align=right>品脱(pt)</TD>
                  <TD align=left><INPUT size=12 name=uslPint class="SmallInput"></TD>
                  <TD align=left><INPUT onclick="if (checkNum(uslPint.value)) compute(this.form,uslPint.name,vol_data)" type=button value=换算  class=朙SmallButton朙  name=uslPint_bt></TD>
                </TR>
                <TR>
                  <TD noWrap align=right>及耳(gi)</TD>
                  <TD align=left><INPUT size=12 name=uslGill class="SmallInput"></TD>
                  <TD align=left><INPUT onclick="if (checkNum(uslGill.value)) compute(this.form,uslGill.name,vol_data)" type=button value=换算  class=朙SmallButton朙  name=uslGill_bt></TD>
                  <TD noWrap align=right>液量盎司(fl oz)</TD>
                  <TD align=left><INPUT size=12
                            name=uslFluid_ounce class="SmallInput"></TD>
                  <TD align=left><INPUT onclick="if (checkNum(uslFluid_ounce.value)) compute(this.form,uslFluid_ounce.name,vol_data)" type=button value=换算  class=朙SmallButton朙  name=uslFluid_ounce_bt></TD>
                </TR>
                <TR>
                  <TD noWrap align=right>液量打兰(fl dr)</TD>
                  <TD align=left><INPUT size=12
                            name=uslFluid_dram class="SmallInput"></TD>
                  <TD align=left><INPUT onclick="if (checkNum(uslFluid_dram.value)) compute(this.form,uslFluid_dram.name,vol_data)" type=button value=换算  class=朙SmallButton朙  name=uslFluid_dram_bt></TD>
                  <TD noWrap align=right>量滴(min)</TD>
                  <TD align=left><INPUT size=12 name=uslMinim class="SmallInput"></TD>
                  <TD align=left><INPUT onclick="if (checkNum(uslMinim.value)) compute(this.form,uslMinim.name,vol_data)" type=button value=换算  class=朙SmallButton朙  name=uslMinim_bt></TD>
                </TR>
                <TR align="center">
                  <TD  colSpan=6><B><br>
                  美英同制体积计量</B>
                    <HR SIZE=1>
                  </TD>
                </TR>
                <TR>
                  <TD noWrap align=right>亩英尺</TD>
                  <TD align=left><INPUT size=12 name=uscAcre_foot class="SmallInput"></TD>
                  <TD align=left><INPUT onclick="if (checkNum(uscAcre_foot.value)) compute(this.form,uscAcre_foot.name,vol_data)" type=button value=换算  class=朙SmallButton朙  name=uscAcre_foot_bt></TD>
                  <TD noWrap align=right>立方码</TD>
                  <TD align=left><INPUT size=12
                            name=uscCubic_yard class="SmallInput"></TD>
                  <TD align=left><INPUT onclick="if (checkNum(uscCubic_yard.value)) compute(this.form,uscCubic_yard.name,vol_data)" type=button value=换算  class=朙SmallButton朙  name=uscCubic_yard_bt></TD>
                </TR>
                <TR>
                  <TD noWrap align=right>立方英尺</TD>
                  <TD align=left><INPUT size=12
                            name=uscCubic_foot class="SmallInput"></TD>
                  <TD align=left><INPUT onclick="if (checkNum(uscCubic_foot.value)) compute(this.form,uscCubic_foot.name,vol_data)" type=button value=换算  class=朙SmallButton朙  name=uscCubic_foot_bt></TD>
                  <TD noWrap align=right>立方英寸</TD>
                  <TD align=left><INPUT size=12
                            name=uscCubic_inch class="SmallInput"></TD>
                  <TD align=left><INPUT onclick="if (checkNum(uscCubic_inch.value)) compute(this.form,uscCubic_inch.name,vol_data)" type=button value=换算  class=朙SmallButton朙  name=uscCubic_inch_bt></TD>
                </TR>
              </TBODY>
            </TABLE>
            <br>
            <DIV align=right>              <div align="center">
              <INPUT onclick=resetAll(this.form) type=button value=数据重置 class=朙SmallButton朙  name=res7>
              </div>
            </DIV>
      </FORM></TD>
    </TR>
  </TBODY>
</TABLE>
</body>
</html>


0
0
收藏0

本文来自武鸣人网站,转载请注明出处

本文地址:https://www.wuming.ren/a/938.html

回帖

体积和容积换算js脚本代码 期待您的回复!

取消
载入表情清单……
载入颜色清单……
插入网络图片

取消确定

图片上传中
编辑器信息
提示信息