复杂的Javascript计算 [英] Complicated Javascript Calculation

查看:130
本文介绍了复杂的Javascript计算的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个相当大的表,需要有一个在右侧和底部的总计每日总计。

I've got a fairly large table that needs to have a total on the right side and bottom for daily totals.

我已经能够获得侧到总正确,但不是底部。

I've been able to get the side to total correctly, but not the bottom.

我可能想的太少,但目前我有这个:(是的,我知道这不正确,不工作,我正在测试) p>

指令码:



I may be thinking too little of this, but currently I have this: (Yes, I know it's not correct and doesn't work. I was testing)

HorizVertiCalc = function(h, v){
  $('.R'+r).sum("keyup", ".vttl"+v);

  $('.C'+v).sum("keyup", ".vtotal"+r+v);
} 



标记:



markup:

<cfloop from="1" to="#ArrayLen(labels)#" index="r">
  <tr>
    <td class="labels"><cfif ArrayIsDefined(labels,r) AND labels[r] NEQ "Open">#labels[r]#</cfif></td>
    <cfloop from="1" to="7" index="i">
      <td id="Day#i#" class="row#r# col#i#">
        <cfif r EQ 1>#Left(DayOfWeekAsString(i),3)#<cfelse><cfif r EQ 2><input type="text" class="date-mask" /><cfelse><input type="text" class="calc R#r# C#i# vtotal#r##i#" onkeypress="return HorizVertiCalc(#r#, #i#)" /></cfif></cfif></td>
    </cfloop>
    <td class="totals"><cfif r EQ 1>Total<cfelse><input type="text" class="ttl#r# vttl#i#" readonly="readonly" /></cfif></td>
  </tr>
</cfloop>

正如你所看到的,我使用循环生成表,所以我需要得到总计为每列和每行。

As you can see, I'm producing the table with loops, and so I need to get the total for each column and each row.

推荐答案

如果换行,它是否工作

function(h, v)

function(r, v)

因为你是指r的行,而不是h?

since you are referring to r for the row, not h?

否则,更基本上我不明白$('。R'+ r)实例将工作,在这里你会最终与任何具有类.R#?当然,我不知道冷灌注

Otherwise, more basically I don't see how $('.R'+r) for instance ever would work, where in here would you end up with anything that has a class .R# ? Granted, I don't know coldfusion

这篇关于复杂的Javascript计算的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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