Hi,
is there a way to find out the value in the cell before and after it is changed in javascript or jQuery? I am thinking I might have to use combination of events like onfocus and onblur. please let me know.
Thanks, sridhar.
Hi,
is there a way to find out the value in the cell before and after it is changed in javascript or jQuery? I am thinking I might have to use combination of events like onfocus and onblur. please let me know.
Thanks, sridhar.
You could use jQuery to write the old value to a hidden field on the page and then have access to both the current value from the edited field, and the old value from the hidden field.
Ofcourse it is possible. Method I prefer to store temporary data is to store them inside object/variable. I am just not sure if you refer to table cell or database cell, but essentially it makes no difference. Using focus it would go like this:
var $temp_before;
var $temp_after;
$('#cell_id').focus(function(){
$temp_before = this.html(); // or this.text() depending on what you want to record
/*... call to function to change it ...*/
$temp_after = this.html();
});
As comment from Cory Larson suggests, you can also store data inside the element itself using jQuery data.
$('#cell_id').focus(function(){
this.data("old_content", this.html());
/*... call to function to change it ...*/
this.data("new_content", this.html());
});