Women in Technology

Hear us Roar



Article:
  PHP Form Handling
Subject:   Display selected value in radio buttons when previous button is clicked
Date:   2008-04-24 12:34:16
From:   radice
Response to: Display selected value in radio buttons when previous button is clicked

Sorry. Here is the correct code.
// This displays Question 0
function displayQuestionOne() {
$answer = $_SESSION['answerArray'][0];
echo "Answer".$answer;
$choice1 = $choice2 = $choice3 = $choice4 = '';
if ($answer == "Opens") $choice1='checked';
if ($answer == "Opened") $choice2='checked';
if ($answer == "Open") $choice3='checked';
if ($answer == "will opened") $choice4='checked';
echo "Choice 1".$choice1."
";
echo "Choice 2".$choice2."
";
echo "Choice 3".$choice3."
";
echo "Choice 4".$choice4."
";


?>
<tr>
<td colspan="3">

Select the correct answer

</td>
<td width="13%"> </td>
</tr>
<tr>
<td width="7%">1.</td>
<td colspan="2">Maria, ____________the door please. It’s too hot in here.</td>
<td> </td>
</tr>


<tr>
<td> </td>
<td colspan="2">


<input type="radio" name="Question" value="Opens" <? $choice1 ?> /> Opens

<input type="radio" name="Question" value="Opened" <? $choice2 ?>/> Opened

<input type="radio" name="Question" value="Open" <? $choice3 ?>/> Open

<input type="radio" name="Question" value="will opened" <? $choice4 ?>/> will opened

</td>
<td> </td>
</tr>
<?


}
?>