ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.

advertisement

AddThis Social Bookmark Button
Article:
  PHP Form Handling
Subject:   Display selected value in radio buttons when previous button is clicked
Date:   2008-04-24 12:30:38
From:   radice
Hello


I have created some evaluation pages. It is one page when i am keeping track of question and displaying the question when next and previous is clicked. I have a problem of displaying the previously selected values in the radio buttons when going back and forward. Here is the code i used.


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';


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

Select the correct answer

</td>
<td width="13%"> </td>
</tr>
<tr>
<td width="7%">1.</td>
<td colspan="2">Sample Question 1</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" /> Opened

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

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

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


}


?>



Any help is appreciated.


Thanks
Radice


1 to 1 of 1
  1. Display selected value in radio buttons when previous button is clicked
    2008-04-24 12:34:16  radice [View]

1 to 1 of 1