English 中文(简体)
采用混合(功能)更新生活计算
原标题:Using .blur(function() to update live calculation

I m试图使用.blur <>/code>,更新基于<代码>的计算功能。 例如,当用户首先从<代码>0改为1时,则当该盒子在赢得之前的计算结果后发生变化时,该盒子就投入使用。 <代码>#to_condition:id 原文<编码>10<>。

var bent_num = 0.5;
var bent_orig = $("#is_bent_num").val();
$("#is_bent_num").blur(function(){
    var bent_new = $("#is_bent_num").val();
    updatecondition(bent_num * bent_orig * -1);
    updatecondition(bent_num * bent_new);
    bent_orig = bent_times;
});

function updatecondition(newcondition){
    var changecondition = $("#condition_exact").val() - newcondition;
    $("#condition_exact").val(changecondition);
    if (changecondition < 0){
        changecondition = 0;
    }
    changecondition = changecondition.toFixed(1);
    $("#to_condition").text(changecondition);
}
问题回答

詹姆斯,我认为你 did了整个法典,例如,遗体的定义缺失。 然而,在我看来,头两条更新路线显然是造成你问题的原因。 您应始终从美元(“#is_bent_num”)中减去。

当职能更新要求时,结果就算成“定点”,取决于分配给该职能的新的定点参数和“标准-实际价值”,而后者则每当需要更新的康迪诺时随时更新。 或许,更新“基本条件——实际价值”是造成你问题的原因?

$("#condition_exact").val(changecondition);

我认为,你的问题是:

updatecondition(bent_num * bent_orig * -1);
updatecondition(bent_num * bent_new);

您基本上更新了<代码>#condition_exact Field twice ;一面价值基于bent_num,一面价值基于用户投入(bent_new)。 第二次更新(当然是)你将看到的更新。 我认为你打算做的是:

updatecondition(bent_orig - (bent_num * bent_new));

现在,外地将只更新。 新的价值将是原始价值,减去用户投入时间bent_num

顺便说一句,您的变量名称令人困惑。 例如,<代码>bent_num指的是什么? 这是否是步骤规模? 想看这一法典的人是否知道它意味着什么? (我肯定没有。) 如果你在6个月后再次研究该守则,你是否会? 因此,如果<代码>bent_num 是级大小,为什么不将其称作size(或pan)?





相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.