0
不知道我在做什么错在这里,但我有一个网页,有一个usercontrol包裹在更新面板。这个用户控件有一个GridView,在ItemTemplate中有一个文本框,在页脚模板中有一个文本框。 footertemplate中的文本框应该从jquery中的函数中获取计算值。下面是我的脚本来获得总数,但总数没有得到计算。请告知我在这里做错了什么。另外,让我知道是否需要提供更多信息。该脚本位于母版页中。我测试了一下,确保jquery在文档准备完成后将警报置于工作状态。任何帮助将不胜感激。在网格上添加总计不工作通过jquery
<script language="javascript">
var totalQuantity = 0;
$(document).ready(function() {
//alert('This is test');
$(document).on('blur', 'input[id^="MainContent_MainContent_ucProjectionSet3_upProjections"]', function() {
alert('This is test');
totalQuantity = 0;
$('input[id^="MainContent_MainContent_ucProjectionSet3_gvProjections_txtCurrentTime_"]').each(function(index) {
doTotalCal($(this).attr("id"));
});
});
function doTotalCalc(_id) {
var indexVal = _id.Replace("MainContent_MainContent_ucProjectionSet3_gvProjections_txtCurrentTime_", "");
console.log(indexVal);
var strTotalQuantity = $('input[id^="MainContent_MainContent_ucProjectionSet3_gvProjections_txtCurrentTime_' + indexVal + '"]').val().replace("$", "");
totalQuantity += Number(strTotalQuantity);
}
$("#MainContent_MainContent_ucProjectionSet3_gvProjections_lblCurrentTimeTotal").html(totalQuantity);
});
</script>