水平和垂直复杂的JavaScript计算和冷融 [英] Horizontal and Vertical complicated Javascript Calculation and Coldfusion

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

问题描述

现在表中填充了2个循环和一个数组。我必须通过输入的类来控制一切。在这个工作了一段时间,一些洞察将有所帮助。

Now the table is being populated with 2 loops and an array. I have to control everything through the classes I put on the input. Been working on this for a while, some insight would be helpful.

以下是循环和输入:

            <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="R#r# C#i#" onkeypress="return HorizVertiCalc(#r#, #i#)" /></cfif><cfif r EQ 25><input type="text" class="dailyTot#r#" onkeypress="return VertiCalc(#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>

这里是我目前的Javascript:

And here is the Javascript I've got at the moment:

         HorizVertiCalc = function(h, v){
            $('.R'+h).sum("keyup", ".ttl"+h);
            $('.C'+v).sum("kepup", ".dailyTot"+h);

            if($('.R'+h) == $('.R4')){
                Number($(this).val()) * <cfoutput>#mileage#</cfoutput>;
                $(this).sum("keypup", ".R5");
                }
            } 

        VertiCalc = function(v){

            alert($('.C'+v));
        }



我需要能够获得每日总计和总和总计每个类别(我现在可以做的。)。另外,我需要能够将鼠标#乘以特定于变量#mileage#的数字,并且该单元格的总数直接在它下面。

I need to be able to get the daily totals and the grand total and the totals each category (which I'm able to do right now.). Also, I need to be able to multiply the milage # by the number specific with the variable #mileage# and have the total for that cell be directly below it.

好吧。这是很多,如果有人可以给一些帮助,将非常感谢!

Well. It's a lot and if anyone can give some help, it would be greatly appreciated!

推荐答案

不知道你的代码是如何工作,这里有几个建议/意见:

Without knowing exactly how your code is working, here are a couple of suggestions/observations:

我注意到你有keyup,kepup和keypup。

I notice that you have "keyup", "kepup" and "keypup". Are they all meant to be different?

不确定Number()的作用,但你可以使用一个parseFloat()可能结合isNaN()检查执行数学。

Not sure what Number() does exactly, but you could use a parseFloat() possibly in conjunction with an isNaN() check before performing the math.

我假设你的Javascript代码是jQuery?你正在做一个jQuery比较:if($('。R'+ h)== $('。R4'))
我怀疑这可能总是返回false
此页:)
http://groups.google。 com / group / jquery-en / browse_thread / thread / 002d7543186ddaa6

I'm assuming your Javascript code is jQuery? You are doing a jQuery comparison: if($('.R'+h) == $('.R4')) I have a suspicion that this might always return false (as suggested by this page:) http://groups.google.com/group/jquery-en/browse_thread/thread/002d7543186ddaa6

James

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

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