如何在堆栈中添加值 [英] How to add Values in a stack

查看:104
本文介绍了如何在堆栈中添加值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我有一堆数字,用于在图表中显示...

我想添加这些数字并在标签中显示数字...

我该怎么做?

<前lang =Javascript> $。ajax({
url:' <%= ResolveUrl(〜/ Corporate / Sales.aspx / GetZoneData)%>'
数据: {'rbtlSales':' + selectedValue + < span class =code-string> '}
dataType: json
类型: POST
contentType: application / json; charset = utf-8
成功:有趣ction (数据){
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);
}) ;





最后一行dd包含值...我想添加它们并将其显示在标签中...



问候,

Sajin A

解决方案

.ajax({
url:' <%= ResolveUrl(〜/ Corporate / Sales.aspx / GetZoneData)%>'
data: {'rbtlSales':' + selectedValue + '}
dataType: json
类型: POST
contentType: application / json; charset = utf-8
成功:功能(数据){
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);
});





最后的l ine dd包含值...我想添加它们并将其显示在标签中...



问候,

Sajin A


我找到了解决方案...



  var  lblmsg =  总销售额为 +  eval (datas.join('  +')); 
document .getElementById(' <% = lblTotal.ClientID%>')。innerHTML = lblmsg;


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?

$.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

解决方案

.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


I have found a solution...

var lblmsg = "Total Sales is " + eval(datas.join('+'));
document.getElementById('<%=lblTotal.ClientID %>').innerHTML = lblmsg;


这篇关于如何在堆栈中添加值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆