I have a database-driven test that I want to modify so that users can't submit the results unless they've tried to answer all the questions. I can simply insert "required" in most of the questions, but that doesn't work with questions that have multiple checkboxes as answers.
Someone suggested the following fix:
$required = ($Value == 0) ? "required" : ""; //condition to check if the value is first. since it is database driven it would be better to check the key instead of the value.;
$QA = '<label for="q'.$QID.'-'.$Value.'"><input type="checkbox" name="q'.$QID.'" id="q'.$QID.'-'.$Value.'" value="'.$Value.'" '. $required .'> '.$QA.'</label>';
However, it inserts "required" with EVERY checkbox, which means a user can't submit the results unless they select every answer. Does anyone know how to fix this?
Also, what does the comment "it would be better to check the key instead of the value" mean? I don't understand what he meant by "key."
Aucun commentaire:
Enregistrer un commentaire