---
title: "How to get previous selection of dropdown value when I click button?"  
description: "How to get previous selection of dropdown value when I click button?"  
author: "Anonymous User"  
published: 2013-04-08  
updated: 2013-04-08  
canonical: https://www.mindstick.com/forum/730/how-to-get-previous-selection-of-dropdown-value-when-i-click-button  
category: "javascript"  
tags: ["javascript"]  
reading_time: 1 minute  

---

# How to get previous selection of dropdown value when I click button?

Hi [Expert](https://www.mindstick.com/articles/13120/an-expert-financial-advice-will-improve-your-finances)!\
How to get [previous](https://yourviews.mindstick.com/view/81421/unlock-2-0-is-just-like-previous-corona-lockdowns) [selection](https://www.mindstick.com/blog/60/populate-records-in-second-listbox-according-to-the-selection-in-first-list-box) of [dropdown](https://www.mindstick.com/articles/263/ajax-toolkit-dropdownextender-in-asp-dot-net) [value](https://www.mindstick.com/articles/23219/an-optimized-description-adds-value-to-experience-and-in-turn-effectively-guest-posting-packages) when I [click button](https://www.mindstick.com/forum/34274/how-to-pass-combobox-value-from-windows-form-edirrow-to-windows-form-form1-where-click-button). I refer below [coding](https://www.mindstick.com/articles/12290/teaching-coding-from-the-metal-up-or-from-the-glass-back)\
$(".addToButton").live('click', [function](https://www.mindstick.com/articles/13001/multi-statement-table-valued-user-defined-function-in-sql-server) (e) { var sel = $(this).prevAll(".addToList:first"), val = sel.val(), text = sel.find(':selected').text(); });But it is not working. How should I get previous selection of dropdown value when I click button?\
Thank in [advance](https://www.mindstick.com/blog/33258/jee-mains-and-jee-advance-exams)!\

## Replies

### Reply by AVADHESH PATEL

Hi Ezra!\
Try as following line of code\

```
    (function () {            var prevVal;            $("select").focus(function () {                // For storing current value on focus and on change                prevVal = this.value;            }).change(function() {                // Get new value in previous varible storage                prevVal= this.value;            });          $("btnGet").click(function(){ alert("This is previous value: "+prevVal);});        })();
```

\
Hope its helpful for you!


---

Original Source: https://www.mindstick.com/forum/730/how-to-get-previous-selection-of-dropdown-value-when-i-click-button

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
