I\'m trying to use jQuery to make an ajax request based on a selected option.
Is there a simple way to retrieve the selected option id (e.g. \"id2\"
Th easiest way to this is var id = $(this).val(); from inside an event like on change.
var id = $(this).find('option:selected').attr('id');
then you do whatever you want with selectedIndex
I've reedited my answer ... since selectedIndex isn't a good variable to give example...
$('#my_select option:selected').attr('id');
You can get it using the :selected selector, like this:
$("#my_select").change(function() {
var id = $(this).children(":selected").attr("id");
});