Click here to Skip to main content
15,889,216 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a panel named "listState" on my aspx page

Now in that panel i have number of dropdowns.
I want id of that all dropdownlist present in "listState"

How can i do this using JQUERY

I tried following code

$('#<%=listState.ClientID%>').find("select")
But it doesnt gives me id of all dropdownlist.

What to do to achieve this.
Posted

Here you go

JavaScript
$(document).ready(function () {
            var name = [];
            var input = $("#<%= Panel1.ClientID %>").find("select").each(function (i) {
                name[i] = $(this).attr('id');
                //alert($(this).attr('id'));
                //alert($(this).attr('name'));
            });
        });
 
Share this answer
 
Comments
AditSheth 15-Sep-11 1:51am    
my vote for 5
its perfect
Suresh Suthar 15-Sep-11 2:05am    
Thanks Adit.
Hi,

Try this-

XML
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.5.js" type="text/javascript"></script>
<script type="text/javascript">
    var dropdownIDsArray = new Array();
    $(document).ready(function () {
        dropdownIDsArray = $.map($("div[id*=listState]").find("select"), function (item, index) {
            return $(item).attr("id");
        });
        debugger;
    });
</script>
</head>
<body>
    <form id="form1" runat="server">
    <div id="listState">
     <select id="myDDL" ></select>
    <br />
    <select id="other"></select>
    </div>
    </form>
</body>
</html>
 
Share this answer
 

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