0

My main problem was I was trying to get values from my form and selectboxes are using selectpicker jquery plugin, they look really cool now! But in other I found a bug, when I put default selected by html tag "selected" it always gives selected value.

https://github.com/silviomoreto/bootstrap-select

I'm trying to get value by this code but it always return same value.

var pets_name = $('#pets_name').val(); 
Jack Bonneman
  • 1,821
  • 18
  • 24
Mehmet Uyarovic
  • 304
  • 2
  • 9
  • Duplicate? http://stackoverflow.com/questions/14804253/how-to-set-selected-value-on-select-using-selectpicker-plugin-from-bootstrap – victoryNap Aug 12 '14 at 22:01

1 Answers1

0

I tried to search setting default value option but I couldn't find anything about it on seletpickers github.

I solved my problem by this code. :selected gives us this value. I hope it will help someone,sometimes we need small fixes not big ones.

var pets_name = $('#pets_name:selected').val();
Tushar Gupta - curioustushar
  • 58,085
  • 24
  • 103
  • 107
Mehmet Uyarovic
  • 304
  • 2
  • 9