I have asp dropdownlist populated from database and two divs. I want when I select any item of the dropdownlist to hide existing div and show another one if i select the first item the opposite . here is my code:
<asp:DropDownList runat="server"
ID="brandsList"
AutoPostBack="True"
DataSourceID="brandsDataSource"
DataTextField="BrandName"
DataValueField="BrandId"
OnDataBound="brandsList_DataBound"
OnSelectedIndexChanged="brandsList_SelectedIndexChanged"
ClientIDMode="Static">
</asp:DropDownList>
C# code for my dropdownlist:
if (brandsList.Items.Count > 0)
{
brandsList.Items.Insert(0, " * SELECT BRAND *");
brandsList.Items[0].Value = "1";
brandsList.SelectedIndex = 0;
}
javascript code:
<script type="text/javascript">
$(function () {
$("<%=brandsList.ClientID%>").change(function () {
ToggleDropdown();
});
ToggleDropdown();
});
function ToggleDropdown(){
if ($("<%=brandsList.ClientID %>").val() != "1") {
$("#cats").hide(); $("items").show();
}
else { $("#cats").show();$("#items").hide(); }
};
</script>
P.S : I want to show the both divs in the same place
thx in advance!
Sam