根据下拉选择切换可见性

时间:2015-12-01 20:36:56

标签: javascript css asp.net

我目前正在尝试根据下拉列表选择的值切换某些字段的可见性。目前我有以下代码:

使用Javascript:

 function collapseScreeningRequiredList(elementRef) {
        var txt = document.getElementById('<%=txtScreeningDate.ClientID %>');
        var buttonSave = document.getElementById('<%=btnSaveScreeningDate.ClientID %>');
        var label = document.getElementById('<%=lbltxtScreening.ClientID %>');
        var required = document.getElementById('<%=lblScreeningRequired.ClientID %>');
        if (elementRef.value == "Yes") {
            txt.style.visibility = 'visible';
            buttonSave.style.visibility = 'visible';
            label.style.visibility = 'visible';
            required.style.visibility = 'visible';
            elementRef.style.width = elementRef.normalWidth;
        } else if (elementRef.value == "No") {
            txt.style.visibility = 'hidden';
            buttonSave.style.visibility = 'hidden';
            label.style.visibility = 'hidden';
            required.stye.visibility = 'hidden';
        }
    }

ASP.NET标记:

<asp:DropDownList ID="ddlRequired" CssClass="DropDownList" runat="server" TabIndex="33" Height="20px" Width="200px" normalWidth="200px" onmousedown="expandDropDownList(this);"onblur="collapseDropDownList(this);"onchange="collapseScreeningRequiredList(this);">

代码实际上是除了,这是我第一次对下拉列表进行更改。有人可以帮我解决我在这里做错了吗?

0 个答案:

没有答案