如何计算总和 [英] how to calculate the sum
本文介绍了如何计算总和的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有四个文本框
前两个texbox显示总和
最后两个文本框显示了当我向下光标时如何自动求和的总和
计算总和.无需使用任何脚本语言.是否可以编写代码
文本框.
i have four textboxes
first two texboxes show the sum
and last two textboxes show the sum when i am curser down how to automatically
calculate the sum. with out use any script language. is it posible to write code
textbox.
推荐答案
function CalculateSum()
{
var Form = document.frmsum;
var txtbx1= Form.txt1.value;
var txtbx2 = Form.txt2.value;
var txtbx3 = Form.txt3.value;
var txtbx4 = Form.txt4.value;
var allsum = Number(txtbx1)+Number(txtbx2)+Number(txtbx3)+Number(txtbx4);
if(!isNaN(allsum) && allsum !=Infinity)
{
Form.txtsum.value = allsum;
}
return CheckZero()
}
页面加载
on page load
txtsum.Attributes.Add("onblur", "return CalculateSum()");
谢谢
Ashish
Thanks
Ashish
如果不处理文本框的任何事件,则无法显示总和.您应该处理JavaScript事件以显示总和.
--Amit
This is not possible to show the sum without handling any event of the textboxes. You should handle the JavaScript event to show the sum.
--Amit
在事件属性中有Mouse Down事件和Mouse up事件,请单击该事件,在附带事件中执行代码
There is Mouse Down Event and Mouse up event is there in event property click that event and in side event do your code
这篇关于如何计算总和的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文