Checkbox processing


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. // FORM:
  2. <input type="checkbox" class="community" name="community[]" value="Lakewood Court Townhomes" id="i-lake" />
  3. <input type="checkbox" class="community" name="community[]" value="Belmont Court Condominiums" id="i-belm" />
  4.  
  5. // PROCESSING PAGE:
  6. $checkboxarray = $_POST[ 'community' ];
  7. for ( $i = 0; $i <= count($checkboxarray); $i++ ) {
  8. $checkboxvar .= $checkboxarray[$i];
  9. if ( $i < (count($checkboxarray) - 1) ) {
  10. $checkboxvar .= ', ';
  11. }
  12. }
  13. echo $checkboxvar;

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.