Reputation: 350
i have a problem to get the value of a selected value from a dropdownlist
my code jquery is : $( "#statistic_commune option:selected" ).text();
this code work when i use just html like : select.form-control name="statistic[state]" id="statistic_commune "
but it doesn't work when i use : rails tag like = towns_select_tag(:statistic, :commune, {include_blank: true}, {class: 'form-control'},{id: 'statistic_commune'})
help please
Upvotes: 0
Views: 2264
Reputation: 3449
You should do like this
= towns_select_tag(:statistic, :commune, {include_blank: true}, {class: 'form-control'}, :id => "statistic_commune")
You should get value by using:
$('#statistic_commune').val();
Upvotes: 2
Reputation: 1197
You need to target the select tag :
$( "#statistic_commune" ).val();
Upvotes: 1