2
<form name="storelocator_cities_form" id="storelocator_cities_form">
    <select name="storelocator_city" id="storelocator_city" onchange="storeLocatorForm.fetchStoresByCountryAndPostCode(this)">
         <option value=""></option>
    </select>
</form>

Hi i want to capture the option value and then compare it to a specific city and i'm stuck. I'am new with both JS and jQuery but i guess that i will need to do something like

jQuery(function(){
    $('#storelocator_city').on('change',function(){
        var city = $(this).val();
    });
});

I would like a way to see that i get the correct value in the var in the console.

Hybrid
  • 128
  • 4
user3351826
  • 23
  • 1
  • 4

1 Answers1

0

I would like a way to see that i get the correct value in the var in the console

Sure , but first :

Why do you have 2 onchange events ?

enter image description here

Anyway - to see the value in console : try this :

jQuery(function(){
     $('#storelocator_city').on('change',function(){
       var city = $(this).val();
       console.log(city); <------- Try this
    });
});
Royi Namir
  • 144,742
  • 138
  • 468
  • 792