js 自动计算并显示

1.  οnblur="setValue()"/>

  οnblur="setValue()" />

 

  function setValue() {
        var e = document.getElementById('ctl00_MainContent_FormView1_合同利率TextBox').value;
        var e1 = document.getElementById("ctl00_MainContent_FormView1_额外利率TextBox").value;
        if (e == "") {
            e = 0;
        }
        if (e1 =="") {
            e1 = 0;
        }
        document.getElementById('ctl00_MainContent_FormView1_实际利率TextBox').value = (parseFloat(e) + parseFloat(e1)) + "%";
    }

 

2.                      GridLines="None" BorderWidth="0px" AllowSorting="true" Style="outline: none"
                    AllowAutomaticUpdates="True" AllowAutomaticInserts="True" AllowPaging="True"
                    PageSize="20" Culture="zh-CN" Width="100%" Height="100%"
                    onitemcreated="rgdLoanbase_ItemCreated">   //每个item需求发送的时候;


                               function setValue() {
                                       
                                         var e = document.getElementById("<%=合同利率TextBoxClientID %>").value;
                                         var e1 = document.getElementById("<%=额外利率TextBoxClientID %>").value;
                                         if (e == "") {
                                             e = 0;
                                         }
                                         if (e1 == "") {
                                             e1 = 0;
                                         }
                                         document.getElementById("<%=实际利率TextBoxClientID %>").value = (parseFloat(e) + parseFloat(e1)) + "%";
                                    }

 

    protected string 合同利率TextBoxClientID;
    protected string 额外利率TextBoxClientID;
    protected string 实际利率TextBoxClientID;

 protected void rgdLoanbase_ItemCreated(object sender, GridItemEventArgs e)
    {
          if (e.Item is GridEditFormItem && e.Item.IsInEditMode)  
        { 
            GridEditFormItem editFormItem = (GridEditFormItem)e.Item;
            TextBox 合同利率TextBox = editFormItem.FindControl("合同利率TextBox") as TextBox;
            合同利率TextBoxClientID = 合同利率TextBox.ClientID;
            TextBox 额外利率TextBox = editFormItem.FindControl("额外利率TextBox") as TextBox;
            额外利率TextBoxClientID = 额外利率TextBox.ClientID;
            TextBox 实际利率TextBox = editFormItem.FindControl("实际利率TextBox") as TextBox;
            实际利率TextBoxClientID = 实际利率TextBox.ClientID; 
        } 
    }

 

你可能感兴趣的:(js 自动计算并显示)