checkbox handling...

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jiaudheen
    New Member
    • Jul 2007
    • 19

    checkbox handling...

    hi i have five check box. it has text as one, two, three ,four and all corrrespondingl y.

    the task is the first four (1 to 4) checkbox can be checked and unchecked independently. Coressponding text of the checked checkbox must be returned . Now if i select last checkbox ( all ) ,the other four check box must also be checked along with (all) check box and text all should return. if i uncheck the all chekbox , the other four check box must also be unchecked.

    can any one help with c# code.. for this...i'm a fresher.
  • phvfl
    Recognized Expert New Member
    • Aug 2007
    • 173

    #2
    Hi,

    Is this a windows form or a web page?

    If this is a windows form put some action onto the CheckChange event of the final checkbox. If this is a webpage then you would have to either use the AutoPostback property of the checkbox or write some javascript to handle the checking/unchecking of the checkbox.

    Comment

    • shweta123
      Recognized Expert Contributor
      • Nov 2006
      • 692

      #3
      Hi,

      You can try this code on onClick Event of allcheck Checkbox.
      <html>
      <head>
      <script Language = "javascript ">
      function chekAll()
      {
      var myArray = new Array()
      If(document.get ElementById('Al lCheck').checke d)
      {
      document.getEle mentById('Check 1').checked = true;
      myArray[0] = document.getEle mentById('Check 1').value
      ..
      ..
      ..
      document.getEle mentById('Check 4').checked = true;
      myArray[3] = document.getEle mentById('Check 4').value
      return myArray;
      }


      }





      </script>
      </head>
      <body>
      <input type="checkbox" Id="Check1" value="Check1">
      ...
      ..
      ..

      <input type="checkbox" Id="Check4" value="Check4">
      <input type="checkbox" Id="AllCheck" value="AllCheck ">
      </body>
      </html>


      Originally posted by phvfl
      Hi,

      Is this a windows form or a web page?

      If this is a windows form put some action onto the CheckChange event of the final checkbox. If this is a webpage then you would have to either use the AutoPostback property of the checkbox or write some javascript to handle the checking/unchecking of the checkbox.

      Comment

      Working...