我已經做了一個代碼來禁用控件時,用戶點擊一個控件。在我的表格上,我有一個TextBox
和一個DropDown
。當用戶點擊一個TextBox
我將disable
DropDown
就像那樣當點擊DropDown
我會禁用TextBox
它工作正常。我怎樣才能使一個禁用控制回到使用Javascript
但是,當用戶點擊Disabled
控制我想啓用該控件。也就是說,如果我在其上禁用我想Enable
這樣說,這對dropdown
太TextBox
點擊..
我的示例腳本如下
<script type="text/javascript">
function toggleDropDownList1()
{
var d=document.getElementById("<%= DropDownList4.ClientID %>");
if(d.disabled)
{
d.disabled=false;
}
else
{
document.getElementById("<%= TextBox1.ClientID %>").disabled = true;
}
}
function toggleDropDownList2()
{
document.getElementById("<%= DropDownList4.ClientID %>").disabled = true;
}
</script>
設計
<asp:TextBox ID="TextBox1" runat="server" onclick="toggleDropDownList2();"></asp:TextBox>
<asp:DropDownList ID="DropDownList4" runat="server" onclick="toggleDropDownList1();">
<asp:ListItem Text="One" Value="1"></asp:ListItem>
<asp:ListItem Text="One" Value="1"></asp:ListItem>
</asp:DropDownList>
是否要通過單擊禁用的控件來啓用禁用的控件?我認爲onclick事件不會禁用禁用控件? – T23 2012-01-11 12:06:25
是啊,我需要 – Dotnet 2012-01-11 12:07:13
與一個div扭曲它,並獲得div的onlick使它回來。 – Aristos 2012-01-11 12:16:29