Click here to Skip to main content
15,898,902 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello sir.
i have two text boxes TxtA, TxtB. i am calaculating sum of these text boxes using javascript function. i have a label on a page. i want to display the sum value on label. how to do this.
my javascript function is below.

XML
<script type ="text/javascript" >
        function fun() {
            var a = document.getElementById("TxtA").value;
            var b = document.getElementById("TxtB").value;
            var sum = parseInt(a) + parseInt(b);
            //alert(sum);

        }
    </script>


with out alert i want to display this value on label.
any body plz help me.
thanking you.
Posted

document.getElementById("Label1").innerText=sum;
//or

document.getElementById("Label1").innerhtml=sum;
 
Share this answer
 
Comments
sathish.jampala 22-Feb-11 6:07am    
thank you sir. but the label is displaying fraction of seconds.
Ankur\m/ 22-Feb-11 6:09am    
What does that mean?!
m@dhu 22-Feb-11 6:13am    
Check what are you adding(sum value) and what the actual result do you want that has nothing to do with label control.
Sunasara Imdadhusen 22-Feb-11 6:08am    
Good answer!
m@dhu 22-Feb-11 6:13am    
Thanks.
Hope this[^]and this[^] might help you.
 
Share this answer
 
Comments
sathish.jampala 23-Feb-11 3:24am    
thank you sir.
It ok to get the the result, but in every postback these lable text cleared. how it is happen, pls clear my problem.
 
Share this answer
 
Comments
Sandeep Mewara 12-Jun-12 2:08am    
This is not an answer. Please use 'Have a Question or Comment' link to respond to an answer. It will notify answerer of your comment such that he can come back and reply.

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