$names = array(
"prequalified" => 'I am prequalified.',
"receive_info" => 'Yes! I would like to receive more information.'
);
function checkbox(array $names){
foreach($names as $name =>$desc) {
if($_REQUEST['name']=='Yes') {
$checked = 'checked'; else{
$checked = '';
}
$checkbox .= '<tr><td colspan="2"><input type="checkbox" name="'.$name.'" value="Yes" '.$checked.' />'.$desc.'</td></tr>';
}
/*** and return the completed checkbox ***/
return $checkbox;
}
With this code, i am hoping my checkbox would be checked off once the form is submitted, i am however unable to get this to work, once the form is submitted, the checkboxes are unticked, any idea how to fix?