Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. JavaScript
  4. enable check box not working

enable check box not working

Scheduled Pinned Locked Moved JavaScript
question
9 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    byka
    wrote on last edited by
    #1

    I have the following code in my aspx page. for some reason disabled=true/false not working, any idea why? function chkboxlistchecking(chkMed,chkBeh,chkReports) { // Go through all items of a check list control var cbkSelect = document.getElementById(chkMed); var cbkAdd = document.getElementById(chkBeh); var cbkEdit = document.getElementById(chkReports); if(cbkSelect.checked == true || cbkAdd.checked == true ) { cbkEdit.checked=true; cbkEdit.disabled=true; }else { cbkEdit.checked=false; cbkEdit.disabled=true; } }

    L D S P 4 Replies Last reply
    0
    • B byka

      I have the following code in my aspx page. for some reason disabled=true/false not working, any idea why? function chkboxlistchecking(chkMed,chkBeh,chkReports) { // Go through all items of a check list control var cbkSelect = document.getElementById(chkMed); var cbkAdd = document.getElementById(chkBeh); var cbkEdit = document.getElementById(chkReports); if(cbkSelect.checked == true || cbkAdd.checked == true ) { cbkEdit.checked=true; cbkEdit.disabled=true; }else { cbkEdit.checked=false; cbkEdit.disabled=true; } }

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      You have coded

      cbkEdit.disabled=true;

      twice. Is this what you mean to do?

      Unrequited desire is character building. OriginalGriff I'm sitting here giving you a standing ovation - Len Goodman

      B 1 Reply Last reply
      0
      • L Lost User

        You have coded

        cbkEdit.disabled=true;

        twice. Is this what you mean to do?

        Unrequited desire is character building. OriginalGriff I'm sitting here giving you a standing ovation - Len Goodman

        B Offline
        B Offline
        byka
        wrote on last edited by
        #3

        mistypo.. still not working

        L 1 Reply Last reply
        0
        • B byka

          I have the following code in my aspx page. for some reason disabled=true/false not working, any idea why? function chkboxlistchecking(chkMed,chkBeh,chkReports) { // Go through all items of a check list control var cbkSelect = document.getElementById(chkMed); var cbkAdd = document.getElementById(chkBeh); var cbkEdit = document.getElementById(chkReports); if(cbkSelect.checked == true || cbkAdd.checked == true ) { cbkEdit.checked=true; cbkEdit.disabled=true; }else { cbkEdit.checked=false; cbkEdit.disabled=true; } }

          D Offline
          D Offline
          DaveAuld
          wrote on last edited by
          #4

          What are you passing into the function? Are you passing the name of the elements as strings, or passing in as the actual object.

          Dave Find Me On: Web|Facebook|Twitter|LinkedIn


          Folding Stats: Team CodeProject

          B 1 Reply Last reply
          0
          • D DaveAuld

            What are you passing into the function? Are you passing the name of the elements as strings, or passing in as the actual object.

            Dave Find Me On: Web|Facebook|Twitter|LinkedIn


            Folding Stats: Team CodeProject

            B Offline
            B Offline
            byka
            wrote on last edited by
            #5

            I am passing checkbox.ClientID

            1 Reply Last reply
            0
            • B byka

              mistypo.. still not working

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              Exactly what is not working?

              Unrequited desire is character building. OriginalGriff I'm sitting here giving you a standing ovation - Len Goodman

              1 Reply Last reply
              0
              • B byka

                I have the following code in my aspx page. for some reason disabled=true/false not working, any idea why? function chkboxlistchecking(chkMed,chkBeh,chkReports) { // Go through all items of a check list control var cbkSelect = document.getElementById(chkMed); var cbkAdd = document.getElementById(chkBeh); var cbkEdit = document.getElementById(chkReports); if(cbkSelect.checked == true || cbkAdd.checked == true ) { cbkEdit.checked=true; cbkEdit.disabled=true; }else { cbkEdit.checked=false; cbkEdit.disabled=true; } }

                S Offline
                S Offline
                Satheesh1546
                wrote on last edited by
                #7

                Hi, please alert the value of cbkEdit, and check whether it is a valid object or not.And make sure that the ID is same.

                B 1 Reply Last reply
                0
                • S Satheesh1546

                  Hi, please alert the value of cbkEdit, and check whether it is a valid object or not.And make sure that the ID is same.

                  B Offline
                  B Offline
                  byka
                  wrote on last edited by
                  #8

                  if you look at my code I setting up checked=True/False and it working, only disabled not working.

                  1 Reply Last reply
                  0
                  • B byka

                    I have the following code in my aspx page. for some reason disabled=true/false not working, any idea why? function chkboxlistchecking(chkMed,chkBeh,chkReports) { // Go through all items of a check list control var cbkSelect = document.getElementById(chkMed); var cbkAdd = document.getElementById(chkBeh); var cbkEdit = document.getElementById(chkReports); if(cbkSelect.checked == true || cbkAdd.checked == true ) { cbkEdit.checked=true; cbkEdit.disabled=true; }else { cbkEdit.checked=false; cbkEdit.disabled=true; } }

                    P Offline
                    P Offline
                    phome
                    wrote on last edited by
                    #9

                    I think u should check the Checklist.clientID. The following code works both in IE and Chrome.

                    <script type="text/javascript" language="javascript">

                        function chkboxlistchecking(chkMed, chkBeh, chkReports) {
                            // Go through all items of a check list control
                            var cbkSelect = document.getElementById(chkMed);
                            var cbkAdd = document.getElementById(chkBeh);
                            var cbkEdit = document.getElementById(chkReports);
                            if (cbkSelect.checked == true || cbkAdd.checked == true) {
                                cbkEdit.checked = true;
                                cbkEdit.disabled = true;
                            } else {
                                cbkEdit.checked = false;
                                cbkEdit.disabled = true;
                            }
                        }
                    </script>
                    

                    <input id="ch_s" type="checkbox">Select</input>
                    <input id="ch_a" type="checkbox">Add</input>
                    <input id="ch_e" type="checkbox">Edit</input>

                    <br /><button onclick="javascript:chkboxlistchecking('ch_s','ch_a','ch_e');">check</button>

                    anyway , u can move cbkEdit.disabled=true out of the if statement.

                    function chkboxlistchecking(chkMed, chkBeh, chkReports) {
                    // Go through all items of a check list control
                    var cbkSelect = document.getElementById(chkMed);
                    var cbkAdd = document.getElementById(chkBeh);
                    var cbkEdit = document.getElementById(chkReports);
                    cbkEdit.checked = (cbkSelect.checked == true || cbkAdd.checked == true)
                    cbkEdit.disabled = true;
                    }

                    Good day,Good job,Good life

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups