我想将两个文本框中的值相乘(txtBox1应包含一个Integer值,txtBox2应包含一个Float值)并将结果放在第三个文本框中.我的代码如下,但它不起作用.调用javascript函数,否则失败.有人可以帮我正确编码:\?谢谢
//the javascript function
function CalculateTotal(id1, id2) {
var txt1 = document.getElementById(id1);
var txt2 = document.getElementById(id2);
var total = txt1 * txt2;
document.getElementById("txtTotal").value = parseFloat(total);
}
//c# code, programmatically adding attribute
txtBox1.Attributes.Add("onBlur", "CalculateTotal('txtBox1, txtBox2')");
Run Code Online (Sandbox Code Playgroud)