How to pass an array of checked/unchecked checkbox values to PHP email generator?

前端 未结 5 1686
眼角桃花
眼角桃花 2020-12-05 22:04

I have added a checkbox to a form that the user can dynamically add rows to. You can see the form here.

I use an array to pass the values for each row to a PHP emai

5条回答
  •  广开言路
    2020-12-05 22:37

    To get checked and unchecked both values in POST place a hidden field with exactly the same name but with opposite value as compared to the original chkbox value such that in this case the value will be '0'

    
    
     
    
    
     $val) {
            //echo "KEY::".$key."VALue::".$val."
    "; if($val == '1') { //replace '1' with the value you want to search $found[] = $key; } } foreach($found as $kev_f => $val_f) { unset($chk_name[$val_f-1]); //unset the index of un-necessary values in array } final_arr = array(); //create the final array return $final_arr = array_values($chk_name); //sort the resulting array again } $chkox_arr = getAllChkboxValues($_POST['chk_name']); //Chkbox Values echo"
    ";
    print_r($chkox_arr);
    ?>
    

提交回复
热议问题