score:0

The result put into #to_condition when the function updatecondition is called depends on both the newcondition parameter sent to the function and the #condition_exact value, and the latter is updated every time the updateconditino is called. Perhaps that update of the #condition_exact value is what is causing your problem?

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

score:0

I think your problem is here:

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

You basically update the #condition_exact field twice; once with a value based on bent_num, and once with a value based on the user's input (bent_new). The second update is (of course) the one you will see. I think what you meant to do was this:

updatecondition(bent_orig - (bent_num * bent_new));

Now the field will be updated only once. The new value will be the original value, minus the user's input times bent_num.

By the way, your variable names are a bit confusing. For example, what does bent_num mean? Is it the step size? Would someone else who looks at this code know what it means? (I certainly don't.) Will you, if you look at the code again in 6 months' time? So if bent_num is the step size, why not call it step_size (or stepSize)?

score:1

James, I think you didn't paste you whole code, e.g. definition of bent_times is missing. However it clearly seems for me that the first two lines of updatecondition are the cause of your problem. You should always substract from $("#is_bent_num").val() isntead of $("#condition_exact").val()


Related Query

More Query from same tag