samedi 21 novembre 2015

PHP: Echoing HTML When Multiple Checkboxes Options Are Checked

I have a checkbox in which I am able to echo a snippet of html when one option or another is checked, but I am unable to echo a snippet of html when a combination of options are checked together. Can you offer a solution?

($form_data['field'][1][0] refers to the actual checkbox generated within a wordpress plugin)

Below is one of many variations I have tried. My inexperience is just beating my head against a wall.

<?php
$CheckBox = $form_data['field'][1][0];
$a = ( "valueA");
$b = ( "valueB");
?>

<?php
     if  ( $CheckBox == $a && $b ) {
     echo '<h2>both values are printed in HTML</h2>';                                
     }
?>

<?php
     if  ( $CheckBox == $a ) {
     echo '<h2>only valueA is printed in HTML</h2>';                                
     }
?>

<?php
     if  ( $PType == $b ) {
     echo '<h2>only valueB is printed in HTML</h2>';                                
     }
?>




Aucun commentaire:

Enregistrer un commentaire