• javascirpt 客户端实现计算 TextBox DropDownLIst


    function setSelectedValue(parUM)//设置dorpdownlist的选定值
    {
        var ddlVUM='<%=FormView1.FindControl("DropDownList2").ClientID%>';
        var i=document.all(ddlVUM).options.length;
        var j;
        for(j=0;j<i;j++)
        {
          if(document.all(ddlVUM).options[j].text==parUM)
          document.all(ddlVUM).selectedIndex=j
          
        }
    }

    function Measurement()
    {
      
        var txtLength= '<%=FormView1.FindControl("lengthTextBox").ClientID%>';
        var txtWidth= '<%=FormView1.FindControl("widthTextBox").ClientID%>';
        var txtHeight= '<%=FormView1.FindControl("heightTextBox").ClientID%>';
         var txtVolume= '<%=FormView1.FindControl("volumeTextBox").ClientID%>';
        var ddlUM='<%=FormView1.FindControl("DropDownList1").ClientID%>';
        var ddlVUM='<%=FormView1.FindControl("DropDownList2").ClientID%>';
       
        var Length=document.getElementById(txtLength).value;
        if(Length=='') Length=0;
        var Width=document.getElementById(txtWidth).value;
        if(Width=='') Width=0;
        var Height=document.getElementById(txtHeight).value;
        if(Height=='') Height=0;
       //var UM= document.all(ddlUM).selectedIndex;
        var UM=document.all(ddlUM).options[document.all(ddlUM).selectedIndex].text; 
        var VUM=document.getElementById(ddlVUM).innerText;
        var Volume;
      
        switch(UM)
        {
           case "M":
       Volume=Length*Width*Height;
       document.getElementById(txtVolume).innerText=Volume;
       setSelectedValue('CBM');
       break;
       
      case "CM":
       Volume=(Length/100)*(Width/100)*(Height/100);
       
       document.getElementById(txtVolume).innerText=Volume;
       setSelectedValue('CBM');
       break;
      case "IN":
       Volume=(Length/12)*(Width/12)*(Height/12);
       document.getElementById(txtVolume).innerText=Volume;
       setSelectedValue('CBFT');
       
       break;
       
      case "FT":
       Volume=Length*Width*Height;
       Volume=(Length/12)*(Width/12)*(Height/12);
       document.getElementById(txtVolume).innerText=Volume;
       setSelectedValue('CBFT');
       
      default:
      {
       Volume=Length*Width*Height;
       document.getElementById(txtVolume).innerText=Volume;
       setSelectedValue('CBM');
      }
      
        }

    }

  • 相关阅读:
    sharepoint JQ获取List列表的值
    微信修改域名回掉
    input设置只读
    MVC-AJAX-JSON
    sharepoint添加子网站
    sharepoint打开解决方案库
    前台获取参数值
    SQL查看表结构以及表说明
    JQ获取对象属性值
    bootstrap table样式
  • 原文地址:https://www.cnblogs.com/lgzh3/p/833715.html
Copyright © 2020-2023  润新知