Populate Dropdownlist items using jQuery
<p>We're generating a dropdownlist in ASP.NET repeater as below -</p>

<pre><code>&lt;asp:DropDownList ID="ddlQty" runat="server"&gt;
    &lt;asp:ListItem Text="0" Value="0" Selected="True" /&gt;
&lt;/asp:DropDownList&gt;
</code></pre>

<p>So there are several dropdownlists generated on the page. For all these lists, I am trying to populate items containing values from <code>1 to 10</code>.</p>

<pre><code>jQuery(document).ready(function () {

    var ddlQty = jQuery("select[id$='ddlQty']");                
    jQuery.each(ddlQty, function () {
        var curDdl = jQuery(this).next();            
        for (i = 1; i &lt;= 10; i++)
            curDdl.append(jQuery('&lt;option&gt;', { value: i, text: i }));
    });
});
</code></pre>

<p>This code doesn't work, Can you please help.</p>

<p>Thank You !</p>

<p><strong>EDIT:</strong></p>

<p>Thank you for all your respones, the issue lied in, <code>generating ID of repeaters</code>, repeaters controls ID were replaced by ***ddlQty_0, so I must use contains wild card in jQuery.</p>

<p><strong>Fixed Code.</strong></p>

<p>jQuery(document).ready(function () {</p>

<pre><code>var ddlQty = jQuery("select[id*='ddlQty']");

jQuery.each(ddlQty, function () {
    var curDdl = jQuery(this);
    for (i = 1; i &lt;= 10; i++)
        curDdl.append(jQuery('&lt;option&gt;', { value: i, text: i }));
});
</code></pre>

<p>});</p>
