Posted By

alexandrepayet on 11/05/10


Tagged


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

romainsauger


Tester une liste de checkbox


 / Published in: PHP
 

  1. <!-- le code html -->
  2.  
  3. <input type="checkbox" name="jury[]" value="11"/>
  4. <input type="checkbox" name="jury[]" value="12"/>
  5. <input type="checkbox" name="jury[]" value="14"/>
  6. <input type="checkbox" name="jury[]" value="15"/>
  7. <input type="checkbox" name="jury[]" value="16"/>
  8. <input type="checkbox" name="jury[]" value="23"/>
  9. <input type="checkbox" name="jury[]" value="26"/>
  10. <input type="checkbox" name="jury[]" value="31"/>
  11.  
  12. <!-- le code php -->
  13.  
  14. <?php
  15.  
  16. //comment tester qu'au moins un checkbox est coché ou pas
  17. if(isset($_POST['jury'])){
  18.  
  19. foreach($_POST['jury'] as $chkbx){
  20.  
  21. //ici à chaque passage $chkbx contiendra le value d'une des case coché
  22. echo $chkbx; //12 16 23 31 ...
  23.  
  24. }
  25. }
  26. ?>

Report this snippet  

You need to login to post a comment.