Click here to Skip to main content
16,012,316 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,
All iam doing an tooltip type validation in my webpage in which i need to get all Dropdowns selected index ,if dropdown selected index is -1 then i should open an tooltip ,the logic for tool tip is working fine,but how to get the selected item index of all my drop downs, i tried something like this didnt workedout.
Pls help me out.atleast in the alert if i get all the dropdowns selected index it will be fine.

JavaScript
var parentsa = $('#aspnetForm');
                          $("input,select", parentsa).mouseover(function () {
                              var selected = $("input,select", parentsa).options[$("input,select", parentsa).selectedIndex].value;
                             
                              $("input,select", parentsa).tooltip("open");
                              alert(selected);

                          });
Posted
Updated 28-Aug-13 23:15pm
v2

SQL
$("select option:selected").each(function(index){
alert($(this).val());
});
 
Share this answer
 
Try this
JavaScript
$("select[name='yourDropDownName'] option:selected").index()

Hope this helps
 
Share this answer
 
Comments
ashok_89 29-Aug-13 4:13am    
Hi,
I have to select all the dropdowns in my page
sumit_810 29-Aug-13 4:19am    
$("select option:selected").each(function(index){
alert($(this).val());
});

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900