dimanche 15 mars 2020

How to get the value of a hidden checkbox

I have two checkbox; one is hidden and the other one is displayed.

echo "<td class='a-center'><input type='checkbox' class='flat' name='table_records' ></td>";
echo "<td class='a-center'><input type='hidden' class='flat' name='selected[" .$row["SERIAL_NUM"]. "]' ></td>";

Below is the code for getting the values:

if (isset($_POST['selected'])){
   if (isset($_POST["selected"])) {
       $checked = array();
       foreach($_POST["selected"] as $number => $val) {
          $checked[] = addslashes($number);
          $serial = $number;

          $_SESSION['success'] = $serial;
       }
    }
}

The code above will only display the last data on the table even when I unchecked the check box. Any ideas? Thank you.




Aucun commentaire:

Enregistrer un commentaire