I am using the Select Menu widget to display a list of states within a form:
<select name="state" id="state">
<option value = "">Select State</option>
<option value = "Alabama">Alabama</option>
<option value= "Alaska">Alaska</option>
<option value= "Arizona">Arizona</option>
<option value= "California">California</option>
<option value= "Colorado">Colorado</option>
<option value= "Connecticut">Connecticut</option>
</select>
In my script I have
$( "#state" ).selectmenu();
Now, what I am trying to do is send out an alert of the value of the selected option. So I have this:
$('select').on('change', function (e) {
var optionSelected = $("option:selected", this);
var valueSelected = this.value;
alert(valueSelected);
});
The issue is that for some reason none of that is working when I use the JQueryUI function selectmenu()
When I remove that one line, everything functions as normal. It was my understanding that I need to include $( "#state" ).selectmenu();
in order to utilize the JQuery UI theme and functionality.
Can anyone enlighten me on what the issue may be. Again, it works fine if I remove that selectmenu line.
Thanks!