2
Reply

HIDE and show fields base on ddl selected

Sajid Hussain

Sajid Hussain

Jan 5 2015 2:29 PM
651
    i have a asp form ,in which i have few controls,there is a drop down value ,i want to show and hide followings fields base on the value selected from the drop down,problem is there is not one value against i want to show or hide the fields ,there are more then two values asp code is
 
            
 <label class="col-sm-2 control-label">                 EmployeeStatus: <span class="symbol required"></span>             </label>             <div class="col-sm-3">                 <asp:DropDownList CssClass="form-control" ID="ddlEmpStatus" runat="server" OnSelectedIndexChanged="ddlEmpStatus_SelectedIndexChanged" AutoPostBack="true" />                 <asp:RegularExpressionValidator runat="server" ID="revddlEmpStatus" ControlToValidate="ddlEmpStatus" Required="required" Display="Dynamic"></asp:RegularExpressionValidator>             </div>
code behind is
protected void ddlEmpStatus_SelectedIndexChanged(object sender, EventArgs e)         {             if (ddlEmpStatus.SelectedValue == "Absent")             {                 ddlDutyType.Visible = false;                 ddlEmployeeShift.Visible = false;                 txtEndDate.Visible = false;                 txtHasWirles.Visible = false;               }             else              {                 txtStartDate.Visible = true;                 txtEndDate.Visible = true;                 ddlDutyType.Visible = true;                 ddlEmployeeShift.Visible = true;                          }           }
i want show these field against LEAVE,SHORTLEAVE,LONGLEAVE,and hide upon Absent ,SpecialDuty etc  

Answers (2)