Solved

jquery replaceWith problem

Posted on 2010-11-10
7
350 Views
Last Modified: 2012-05-10
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?





0
Comment
Question by:MrKevorkian
  • 5
  • 2
7 Comments
 
LVL 7

Expert Comment

by:dxdinh
Comment Utility
try this

$("#myDisplayLabel).val(myCalculatedValue);
0
 
LVL 1

Author Comment

by:MrKevorkian
Comment Utility
hi,

now nothing gets set!  not even the first time?
0
 
LVL 1

Author Comment

by:MrKevorkian
Comment Utility
figured it out - its .text(myCalculatedValue)
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 7

Expert Comment

by:dxdinh
Comment Utility
my bad - I did not pay attention to the label ..... not input text box. :(
0
 
LVL 1

Author Comment

by:MrKevorkian
Comment Utility
do you mind if i  ask for this to be closed
0
 
LVL 1

Accepted Solution

by:
MrKevorkian earned 0 total points
Comment Utility
figured it out - its .text(myCalculatedValue)
0
 
LVL 1

Author Closing Comment

by:MrKevorkian
Comment Utility
i answered my own question
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

OverviewThis article demonstrates a simple search form using AJAX. The purpose of the article is to demonstrate how to use the same code to render a page and javascript (JQuery) and AJAX to make subsequent calls to refine the results. The princip…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now