zoukankan      html  css  js  c++  java
  • 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');
      }
      
        }

    }

  • 相关阅读:
    正则表达式(Python3-re模块示例)
    format函数之几种常规用法
    元组的拆包
    Python3魔术方法实现一摞卡牌
    Python字典的常见操作
    70. Climbing Stairs(js)
    69. Sqrt(x)(js)
    68. Text Justification(js)
    67. Add Binary(js)
    66. Plus One(js)
  • 原文地址:https://www.cnblogs.com/lgzh3/p/833715.html
Copyright © 2011-2022 走看看