Tema: checkbox
Ver Mensaje Individual
  #2 (permalink)  
Antiguo 09/07/2010, 09:42
Avatar de jaullo
jaullo
 
Fecha de Ingreso: abril-2009
Mensajes: 994
Antigüedad: 15 años
Puntos: 30
Respuesta: checkbox

Debes utilizar javascript, algo como esto

Código Javascript:
Ver original
  1. <script type="text/javascript" language="javascript">
  2.     function ChangeCheckBoxState(id, checkState) {
  3.         var cb = document.getElementById(id);
  4.         if (cb != null)
  5.             cb.checked = checkState;
  6.     }
  7.  
  8.     function ChangeAllCheckBoxStates(checkState) {
  9.         // Toggles through all of the checkboxes defined in the CheckBoxIDs array
  10.         // and updates their value to the checkState input parameter
  11.         if (CheckBoxIDs != null) {
  12.             for (var i = 0; i < CheckBoxIDs.length; i++)
  13.                 ChangeCheckBoxState(CheckBoxIDs[i], checkState);
  14.         }
  15.     }
  16.  
  17.     function ChangeHeaderAsNeeded() {
  18.         // Whenever a checkbox in the GridView is toggled, we need to
  19.         // check the Header checkbox if ALL of the GridView checkboxes are
  20.         // checked, and uncheck it otherwise
  21.         if (CheckBoxIDs != null) {
  22.             // check to see if all other checkboxes are checked
  23.             for (var i = 1; i < CheckBoxIDs.length; i++) {
  24.                 var cb = document.getElementById(CheckBoxIDs[i]);
  25.                 if (!cb.checked) {
  26.                     // Whoops, there is an unchecked checkbox, make sure
  27.                     // that the header checkbox is unchecked
  28.                     ChangeCheckBoxState(CheckBoxIDs[0], false);
  29.                     return;
  30.                 }
  31.             }
  32.  
  33.             // If we reach here, ALL GridView checkboxes are checked
  34.             ChangeCheckBoxState(CheckBoxIDs[0], true);
  35.         }
  36.     }
  37. </script>
__________________
http://geekswithblogs.net/jaullo/Default.aspx
Si te he ayudado regalame Karma positivo!!!