Link to home
Start Free TrialLog in
Avatar of MrKevorkian
MrKevorkian

asked on

jquery replaceWith problem

hi there,

(i am using jquery-1.3.2.min.jas
i am also using microsoft mvc )

I have one input text box - when i add a integer value to it - that value is ran against a simple calculation then inserted into a label.

This works fine the first time - but when i update the textbox value - the new calculated value is not inserted into the label - the old calculation remains.

However i have established (via an alert) that the change textbox event is firing - and the updated value is being re-calculated - but the insert is not happening.

here is my code:

 $("input:text").blur(function() {

//do my calculation - then the alert fires with the updated value
alert('my new calculation' + myCalculatedValue);

$("#myDisplayLabel).replaceWith(myCalculatedValue);
//but the value on the screen does not change from the first time the code is run
});

can anyone help?





Avatar of dxdinh
dxdinh
Flag of United States of America image

try this

$("#myDisplayLabel).val(myCalculatedValue);
Avatar of MrKevorkian
MrKevorkian

ASKER

hi,

now nothing gets set!  not even the first time?
figured it out - its .text(myCalculatedValue)
my bad - I did not pay attention to the label ..... not input text box. :(
do you mind if i  ask for this to be closed
ASKER CERTIFIED SOLUTION
Avatar of MrKevorkian
MrKevorkian

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
i answered my own question