Reputation: 741
If i have the bookd_ids and book_titles as follows in the database:
id | title
---------------
1 | abc
2 | xyz
3 | pqr
I have the books dropdownlist as show below:
<%= select("books", "book_id", Book.all.collect {|b|
[ b.title, b.id ] }, {:include_blank => 'Select Book'})%>
i can get the id of the books thru query this way:
var id = $("#books_book_id").val();
How to get the abc, xyz pqr titles using jquery?
Upvotes: 5
Views: 21613
Reputation: 1053
Have put some space between :selected
var value = jQuery("#edit-system-name :selected").text();
Upvotes: 3