Ver Mensaje Individual
  #2 (permalink)  
Antiguo 05/11/2009, 17:26
Avatar de willyfc
willyfc
 
Fecha de Ingreso: octubre-2008
Ubicación: Santa Cruz - Bolivia
Mensajes: 662
Antigüedad: 15 años, 7 meses
Puntos: 40
Respuesta: obtener el valor de un checkbox

de la forma que lo estas haciendo esta bien, solo que cuando lo recoges por POST no tiene el mismo name, tu input es:

<input type="checkbox" name="v_reg_usuAgree" id="v_reg_usuAgree" checked="checked" />

y tu solo lo recoges con v_agree, tendrías que también recogerlo con el name que tiene completo : v_reg_usuAgree, prueba esto:

Código php:
Ver original
  1. <?php
  2. if ($_POST["enviar"])
  3. {
  4.     $valor = $_POST["v_reg_usuAgree"];
  5.     if ($valor == true)
  6.         echo $valor;
  7.     else
  8.         echo "nada";
  9. }
  10. ?>
  11. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  12. <html xmlns="http://www.w3.org/1999/xhtml">
  13. <head>
  14. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  15. <title>Documento sin t&iacute;tulo</title>
  16. </head>
  17.  
  18. <body>
  19. <form action="mihoja.php" method="post">
  20.     <input type="checkbox" name="v_reg_usuAgree" id="v_reg_usuAgree" checked="checked" />
  21.     <input type="submit" value="ch" name="enviar" />
  22. </form>
  23. </body>
  24. </html>

__________________
WFC
codigo82