[英]Call multiple JavaScript functions on onblur
I have to get a running total from four textboxes and have that total populate in two textbox controls.我必须从四个文本框获取总计,并将该总计填充到两个文本框控件中。 I was using
onblur
and that was working fine to display the total in one textbox.我正在使用
onblur
并且可以很好地在一个文本框中显示总数。 When I call this JavaScript function twice on the onblur
event, I get an JavaScript error.当我在
onblur
事件中两次调用此 JavaScript function 时,出现 JavaScript 错误。 Here is my JavaScript function.这是我的 JavaScript function。
function compute(clid, val1, val2, val3, val4) {
var entry1 = Number(document.getElementById(val1).value);
var entry2 = Number(document.getElementById(val2).value);
var entry3 = Number(document.getElementById(val3).value);
var entry4 = Number(document.getElementById(val4).value);
var grandtotal = entry1 + entry2 + entry3 + entry4;
document.getElementById(clid).innerHTML = grandtotal;
}
And here is the codebehind.这是代码隐藏。
protected void Page_Load(object sender, EventArgs e)
{
txtdlscwinter.Attributes.Add("OnBlur", "compute('" + txtdlsctotal.ClientID + "','" + txtdlscwinter.ClientID + "','" + txtdlscspring.ClientID + "','" + txtdlscsummer.ClientID + "','" + txtdlscfall.ClientID + "'); compute('" + txtSpiffDLSC.ClientID + "','" + txtdlscwinter.ClientID + "','" + txtdlscspring.ClientID + "','" + txtdlscsummer.ClientID + "','" + txtdlscfall.ClientID + "');");
}
I am calling the same function twice but passing a different ClientID.我两次调用相同的 function 但传递了不同的 ClientID。 What am I doing wrong here?
我在这里做错了什么?
You need to set value
rather than innerHTML
.您需要设置
value
而不是innerHTML
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.