English 中文(简体)
• 如何使残疾人能够重新获得控制,以利用 Java印
原标题:How can i make a disabled control back to enable using Javascript

在用户点击控制时,我已经做了一项守则,以排除控制。 我的表格是TextBoxDropDown。 当用户点击<代码>TextBox i将disable时,DropDown 如同在上点击时。 DropDown i 将可拆卸<代码>TextBox,该编码可操作。

但当用户点击<代码>可分解控制时,即希望能够进行这种控制。 如在<条码>上点击残疾的电码>TextBox,则如<条码>所示。

My sample Script is as follows

<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>

Design

<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>
最佳回答

www.un.org/Depts/DGACM/index_spanish.htm 想法是把四分之四放在下级名单前面,这四分之三接受“低点”活动。

The issue here is that the div can not place so easy in front of dropdown list. To place it you need to do that dynamically and use the absolut position.

I make here a small code, and test it and working. I have left the background color RED on div to see where it is. Some details I left it to you, eg to find the width and height of your control list, I place the onclick, you can place back the double click, And just remove the red background.

<script type="text/javascript">
function toggleDropDownList1()
{
    var MyDiv = document.getElementById("DivForClick");
    MyDiv.style.display = "none";

    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;

    var MyDdl = document.getElementById("<%= DropDownList4.ClientID %>");
    var MyDiv = document.getElementById("DivForClick");

    MyDiv.style.display = "block";
    MyDiv.style.left = MyDdl.style.left;
    MyDiv.style.top = MyDdl.style.top;

    // need to find the height/width
    // MyDiv.style.height = MyDdl.style.height;
    // MyDiv.style.width = MyDdl.style.width;   
}
</script>

和 as。

<asp:TextBox ID="TextBox1" runat="server" onclick="toggleDropDownList2();"></asp:TextBox>

<br /><br />

<div id="DivForClick" onclick="toggleDropDownList1();" style="z-index:999;position:absolute;left:0;top:0;height:20px;width:40px;background-color:Red;display:none;">
</div>

<asp:DropDownList ID="DropDownList4" runat="server" onclick="toggleDropDownList1();" style="z-index:2;">
   <asp:ListItem Text="One" Value="1"></asp:ListItem>
   <asp:ListItem Text="Two" Value="2"></asp:ListItem>
</asp:DropDownList> 
问题回答

表面上看,“......”和也许其他浏览器、残疾的电离层扰动在残疾的田地上的活动,以及从残疾场开始的任何活动都完全取消,不会传播多功能树。

So, if you want to achieve something like that, you will probably have to do it with a workaround.

不要实际上肢解外地,而是试图将田地划为残疾,这样你才能抓住点击事件。

Do you mean

function toggleIt() {
  var d=document.getElementById("<%= DropDownList4.ClientID %>");
  var t =document.getElementById("<%= TextBox1.ClientID %>");
  d.disabled=!d.disabled
  t.disabled=!t.disabled
}

<asp:TextBox ID="TextBox1" runat="server" onclick="toggleIt();"></asp:TextBox>
    <asp:DropDownList ID="DropDownList4" runat="server" disabled="disabled" onclick="toggleIt();">
        <asp:ListItem Text="One" Value="1"></asp:ListItem>
        <asp:ListItem Text="One" Value="1"></asp:ListItem>
    </asp:DropDownList>




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签