I have 2 dropdowns. On Selected Index change event of ddlTaskFrequency dropdown i want to load another drop down.
For example: If ddlTaskFrequency text= Daily or Weekly i have to load another dropdown ddlDayofMonth with 1,2,3,4,.....31. If it is of Monthly then ddlDayofMonth with 1,2,3,4..12. I want to achieve this using Jquery.Can any one help me on the same.Below is my jQuery
**Jquery**
<script language="javascript" type="text/javascript">
$(document).ready(function () {
$('#' + '<%=this.Panel2.ClientID %>').hide();
$('#' + '<%=this.ddlTaskFrequency.ClientID %>').change(function () {
dropdown = $('#' + '<%=this.ddlTaskFrequency.ClientID %>').val();
if (dropdown == "Day's(at)")
{
$('#' + '<%=this.Panel1.ClientID %>').show();
$('#' + '<%=this.Panel2.ClientID %>').hide();
}
if (dropdown == "Week's(at)") {
$('#' + '<%=this.Panel1.ClientID %>').show();
$('#' + '<%=this.Panel2.ClientID %>').hide();
}
if (dropdown == "Month's(at)")
{
$('#' + '<%=this.Panel1.ClientID %>').hide();
$('#' + '<%=this.Panel2.ClientID %>').show();
}
$('#' + '<%=this.lblNameChange.ClientID %>').text($('#' + '<%=this.ddlTaskFrequency.ClientID %>').val());
return false;
})
});
</script>
**1st dropdown**
<td>
<asp:DropDownList ID="ddlTaskFrequency" runat="server" onselectedindexchanged="ddlTaskFrequency_SelectedIndexChanged" AutoPostBack="true">
<asp:ListItem Selected="True" Text="Daily" Value="Day's(at)"></asp:ListItem>
<asp:ListItem Text="Weekly" Value="Week's(at)"></asp:ListItem>
<asp:ListItem Text="Monthly" Value="Month's(at)"></asp:ListItem>
</asp:DropDownList>
</td>
**2nd dropdown**
<asp:DropDownList ID="ddlDayofMonth" runat="server" Height="18px" Width="80px" AutoPostBack="true"></asp:DropDownList>