Is it possible to get the previous value from the OnChange event from a drop down? I need to see the previous selected value, so that I can make a decision on what I should display.
At the moment, I get the new value:
var id = $('.cmbType').val();
But would like to know what it was before the user selected this value.
You have to store the previous value yourself:
// store initial value
var initialValue = $('.cmbType').val();
$('.cmbType').data('previousValue', initialValue);
// change handler
$('.cmbType').change(function(e) {
var previousValue = $(this).data('previousValue');
// make decision
alert(previousValue);
// store previousValue
$(this).data('previousValue', $(this).val());
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With