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?
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?
Share Improve this question edited Jul 21, 2011 at 16:57 Naftali 146k41 gold badges247 silver badges304 bronze badges asked Jul 21, 2011 at 16:55 KumarKumar 7412 gold badges12 silver badges20 bronze badges2 Answers
Reset to default 13var text = $("#books_book_id option:selected").text();
Have put some space between :selected
var value = jQuery("#edit-system-name :selected").text();