Question: I want to set alert when the value is same. And the value selected is back to previous value
Here is my HTML:

```js
$("#to").val("BGK");
 var fromCity = "";
 var toCity = "";
   $('#from,#to').change(function(){
     var fromCityVal = $("#from").val();
     var toCityVal = $("#to").val();
       if (fromCityVal == toCityVal){
         alert("city of origin may not be the same as the destination city!");
         } 
         else {
           //here's problem, what should I do?
          $("#from").val();
         }
});
```

```html
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<select name="" id="from">
  <option value="DPS">Denpasar</option>
  <option value="BGK">Bangkok</option>
  <option value="MOS">Moscow</option>
</select>

<select name="" id="to">
  <option value="DPS">Denpasar</option>
  <option value="BGK">Bangkok</option>
  <option value="MOS">Moscow</option>
</select>
```

I try this, but not success, What should I do? or any suggestion? Thank you
Here's my code in jsfiddle: <https://jsfiddle.net/dedi_wibisono17/hx1voew9/>

Answer: 
You must storage the previous value as a backup. You can make it with a focus event:

```
    $("#to").val("BGK");
    var item = '';
    var previous = '';
    $('#from,#to').on('focus', function () {
      previous = this.value;
      item = this;
    }). change(function(){
    var fromCityVal = $("#from").val();
            var toCityVal = $("#to").val();
            if (fromCityVal == toCityVal){
                alert("city of origin may not be the same as the destination city!");
                $(item).val(previous);
            } else {
                previous = this.value;
                $("#from").val();
            }
    })

```

This is the working fiddle: 

```js
$("#to").val("BGK");

    var item = '';
    var previous = '';
    $('#from,#to').on('focus', function () {
      previous = this.value;
      item = this;
    }). change(function(){
    var fromCityVal = $("#from").val();
            var toCityVal = $("#to").val();
            if (fromCityVal == toCityVal){
                alert("city of origin may not be the same as the destination city!");
                $(item).val(previous);
            } else {
                previous = this.value;
            }
    })
```

```html
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<select name="" id="from">
  <option value="DPS">Denpasar</option>
  <option value="BGK">Bangkok</option>
  <option value="MOS">Moscow</option>
</select>

<select name="" id="to">
  <option value="DPS">Denpasar</option>
  <option value="BGK">Bangkok</option>
  <option value="MOS">Moscow</option>
</select>
```
At page load , fetch your current selection values in a variable, and map the selection box with this value after alert.