I am new to Asp.net
I am creating website which have DropDown list and few other controls..
Whenever I change dropdown selected index, if it is equals to one of Item then I want to display controls if it is not equals then I want to hide those controls …
Here I tried with this code but not get…
var selectmenu = document.getElementById("<%=ddlCategory.ClientID%>");
var chosenoption = selectmenu.options[selectmenu.selectedIndex];
//Controls which are to hidden or visible
var strCtrlIds = "lblOrderNumber,txtOrderNumber,btnGetOrderNumber,lblItemNumber,txtItemNumber,lblReason,txtReason,lblMaterial,txtDescription";
if (chosenoption.value != "Dry End - Single Stack") {
debugger;
ToggleGivenControl(strCtrlIds, false);
}
else {
ToggleGivenControl(strCtrlIds, true);
}
/**********************************************************
Toggle for Display End- Stack Options
************************************************************/
function ToggleGivenControl(strCtrlIds, blnIsVisible) {
debugger;
var ctrls = strCtrlIds.toString().split(",");
var strCtrlId = '';
for (var intCnt = 0; intCnt < ctrls.length; intCnt++) {
strCtrlId = ctrls[intCnt];
var ctrl = document.getElementById(strCtrlId);
if (ctrl != null) {
if (blnIsVisible) {
ctrl.style.display = 'block';
ctrl.style.visibility = 'visible';
ctrl.focus();
}
else {
ctrl.style.display = 'none';
ctrl.style.visibility = 'hidden';
} //Else End
} //If End.
} //For end.
}
And My asp.net Code is
<asp:DropDown id="ddlCategory" runat="server" />
<asp:Lable id="lblItem" runat="server" />
<asp:TextBox id="txtItem" runat="server"/>
....
And one thing is I bounded dropdown with datasource
please can any one clear my problem?
I think somthink like this.