expanding on my last question how can I store the last selected value from my dropdown but each time the user changes his pick I keep (the previous selected value) and (the current selected value). Do i need to use an array and use push/pop or is there another way to do this?
$(document).on('change', 'select[name=options]', function() {
var prev_selected = $(this).val();
$(this).data('prev_selected',prev_selected);
alert(prev_selected );
//alert(current_selected );
});
HTML
<table id="Final">
<thead>
<th>Tie</th> <th>Pie</th><th>Lie</th>
</thead>
<tr>
<td><select class="Member" name="options">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">ball</option>
<option value="4">4</option></td>
<td>
<select class="Member" name="options" price="200">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option></td>
<td>
<select class="Member" name="options" price="200">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">shoe</option>
<option value="4">4</option></td>
</tr>
</table>
You basically want to capture that previous value on focus, which occurs before the change.
Here’s a similar post answering your question: Getting value of select (dropdown) before change