转载

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 = '';

}

}

}

正文到此结束
Loading...