I am generating a form using php. The form has several checkbox items that user can select. The php code looks similar to this.
function choice_gen ($msgs, $dest) {
$choices = explode("\n", $msgs);
$index = 1;
$return_string = " <div class=\"checkbox_1\">\n";
$return_string .= " <form method=\"post\" action=\"" . $dest . "\">\n";
foreach ($choices as &$choice) {
$return_string .= " <input type=\"Checkbox\" name=\"check_list[]\" id=\"C" . $index . "\" value=\"C" . $index . "\">\n";
$return_string .= " <label for=\"C". $index . "\">$choice</label>\n";
$return_string .= " <BR>\n\n";
$index++;
}
$return_string .= " <input type=\"Submit\" value=\"Next\" class=\"form-submit-button\">\n";
$return_string .= " </form>\n";
$return_string .= " </div>\n";
if (!empty($_POST['check_list'])) {
foreach($_POST['check_list'] as $check) {
$select .= $check;
}
}
return($return_string);
}
$dest is a file name ('somefile.php'). I would like to change the action to "$dest?ch=$select" based on the user input. How do I do this using only PHP (no JS or Ajax etc.)?
Aucun commentaire:
Enregistrer un commentaire