Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
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.
Posted

C#
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

C#
txtsum.Attributes.Add("onblur", "return CalculateSum()");


Thanks
Ashish
 
Share this answer
 
Comments
Vani Kulkarni 6-Aug-12 3:14am    
Good answer!
AshishChaudha 6-Aug-12 3:17am    
Thanks Vani
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
 
Share this answer
 
There is Mouse Down Event and Mouse up event is there in event property click that event and in side event do your code
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900