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 = ‘‘;
                    }
                }

            }

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。