How to disable and enable a checkbox using Javascript

  1. #1

    How to disable and enable a checkbox using Javascript

    I need to disable some checkbox and radio button from checking another checkbox
    I decide to use javascript to accelerate my webpage
    But I cannot find exactly place to add or set attribute
    Please help

    following is my effort code but failed

    
    
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    
    
    <head runat="server">
    
    
    <title></title>
    
    
    
    
    
    <script type="text/javascript" language="javascript">
    
    
    function checkIt() {
    
    
    var check1 = &#100;ocument.getElementById("Checkbox1");
    
    
    var check2 = &#100;ocument.getElementById("Checkbox2_Container");
    
    
    var check3 = Ex
    
    
    var newAttr = &#100;ocument.createAttribute("disabled");
    
    
    
    
    
    //alert(check2.checked)
    
    
    if (check1.checked == true) {
    
    
    newAttr.nodeValue = "disabled"
    
    
    check2.setAttributeNode(newAttr);
    
    
    
    
    
    }
    
    
    
    
    
    
    
    
    }
    
    
    </script>
    
    
    </head>
    
    
    <body>
    
    
    <ext:ScriptManager ID="ScriptManager1" runat="server">
    
    
    </ext:ScriptManager>
    
    
    <form id="form1" runat="server">
    
    
    
    
    
    <ext:Checkbox ID="Checkbox1" runat="server" BoxLabel = "Check1">
    
    
    <Listeners>
    
    
    <Check Fn= "checkIt" />
    
    
    </Listeners>
    
    
    </ext:Checkbox>
    
    
    
    
    
    <ext:Checkbox ID="Checkbox2" runat="server" BoxLabel = "Check2">
    
    
    </ext:Checkbox>
    
    
    <ext:Checkbox ID="Checkbox3" runat="server" BoxLabel = "Check3" Enabled = "false">
    
    
    </ext:Checkbox>
    
    
    
    
    
    
    </form>
    
    
    </body>
    
    
    </html>
    Thank you and best regard
  2. #2

    RE: How to disable and enable a checkbox using Javascript

    Oh, I have found the solution

    After read some place in community, I rendered to http://www.extjs.com/deploy/dev/docs...ember=setValue
    But I cannot navigate to the control which I need to disable

    At last I found this:

    - Use Ext.getCmp("mycontrolID").setDisabled(true/false)

Similar Threads

  1. Replies: 5
    Last Post: Dec 26, 2011, 5:39 AM
  2. Replies: 1
    Last Post: Jul 28, 2011, 4:25 PM
  3. Button Enable/Disable
    By Maia in forum 1.x Help
    Replies: 5
    Last Post: Jul 02, 2010, 8:03 PM
  4. how to disable and enable combobox?
    By sadeque in forum 1.x Help
    Replies: 1
    Last Post: Jul 27, 2009, 5:00 AM
  5. Enable or disable the button
    By VietView in forum 1.x Help
    Replies: 4
    Last Post: Jan 09, 2009, 11:59 AM

Posting Permissions