JS+jquery 计算服务器控件textbox的值并显示在lable上

更好的方法求共同学习。 

//通用
            function Change(clientId) {
                var sampleQuantity = $("input[id*=" + clientId + "_TextBoxSampleNumber]").val();//样本数
                var qualfiedQuantity = $("input[id*=" + clientId + "_TextBoxQualfiedNumber]").val();//合格数
                var labelUnQualfiedNumber = document.getElementById(clientId + "_LabelUnQualfiedNumber");
                var labelYield = document.getElementById(clientId + "_LabelYield");
                if (sampleQuantity != 0) {
                    if (qualfiedQuantity != '') {
                        labelUnQualfiedNumber.innerHTML = (parseFloat(sampleQuantity) - parseFloat(qualfiedQuantity)).toString();
                        labelYield.innerHTML = ((parseFloat(qualfiedQuantity) / parseFloat(sampleQuantity)) * 100).toFixed(3) + "%";
                    } else {
                        labelUnQualfiedNumber.innerHTML = '';
                        labelYield.innerHTML = '';
                    }
                }

            }

posted @ 2015-02-28 09:52  Jerry很简单  阅读(632)  评论(0编辑  收藏  举报