vendredi 9 août 2019

Collect values of multiple checkboxes in PHP (2 submit in same form ?)

I have two submits in the same form. One to filter the mySQL db and generate a list of checkboxes (works fine) and the other to display the values of the selected items using PHP (no go). Later on, I'll store these values to built a sql query. Please visit https://wintoweb.com/sandbox/question.php

I've tried everything you can imagine. Going nuts...

PHP function called from the [Show selected] button :

<?php      
function getNames() {
    //echo 'GOT IT !';              
    if(isset($_GET['choices[]'])){
        if(!empty($_GET['choices'])){
            foreach($_GET['choices'] as $selected){
                echo $selected."</br>";
            }
        }
    }
}
?>

Code for the [Show selected] button :

EXPECTED : the list of selected values below the ACTUAL OUTPUT : no list of selected values. The PHP function getNames() is never traversed.




Aucun commentaire:

Enregistrer un commentaire