Using .blur(function() to update live calculation
<p>I'm trying to use <code>.blur</code> to update a calculation function based off of a <code>select</code> box. It works when the user first changes the box from <code>0</code> to <code>1</code> for example, but when it's changed after that it won't reverse the previous calculation. <code>#to_condition</code> is the <code>id</code> that is displayed in text, originally <code>10</code>. After I change <code>#is_bent_num</code> from <code>0</code> to <code>1</code>, <code>#to_condition</code> is correctly decreasing by <code>0.5</code> to <code>9.5</code>, but if I change it again, say to <code>3</code>, instead of adding <code>0.5</code> back and then subtracting <code>1.5</code> (making <code>#to_condition</code> <code>8.5</code>) it subtracts <code>1.5</code> from the <code>9.5</code>, making <code>#to_condition = 8</code>.</p>

<pre><code>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 &lt; 0){
        changecondition = 0;
    }
    changecondition = changecondition.toFixed(1);
    $("#to_condition").text(changecondition);
}
</code></pre>
