Click here to Skip to main content
15,917,709 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have a stack of numbers which is used to display in chart...
I want to add these numbers and display the numbers in a label...
How can I do that?
JavaScript
$.ajax({
                url: '<%=ResolveUrl("~/Corporate/Sales.aspx/GetZoneData") %>',
                data: "{'rbtlSales':'" + selectedValue + "'}",
                dataType: "json",
                type: "POST",
                contentType: "application/json; charset=utf-8",
                success: function(data) {
                    var labels = [];
                    var datas = [];
                    $.each(data.d, function(i, item) {
                        var l = item.split('-')[0];
                        var d = item.split('-')[1];
                        var dd = d | 0;
                        labels.push(l);
                        datas.push(dd);
                    });


The Last line dd contains values... I want to add them and display it in a label...

Regards,
Sajin A
Posted
Comments
Sinisa Hajnal 17-Dec-15 6:14am    
Why not concatenate "l" variable into some total value string?

1 solution

I have found a solution...

JavaScript
var lblmsg = "Total Sales is " + eval(datas.join('+'));
document.getElementById('<%=lblTotal.ClientID %>').innerHTML = lblmsg;
 
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