I have two pages, in the first page I submit the form which contains Radio buttons.
From the second page, I try to read the responses from the Radio buttons using the $_POST.
The problem is when I hit submit, the $_POST in the second page reads NULL. But when I'm not disabling the Radio buttons in the first page the $_POST form the second page reads the data from the Radio butons correctly.
Is there any solution to make the $_POST reads the values of disabled Radio buttons?
I'm using this Javascript code to disable the radio buttons when the user clicks on it:
function disableRadio(groupName){
var radio=document.getElementsByName(groupName);
for(c=0;c<radio.length;c++)
radio[c].disabled=true;
}
Here is a simple code from each of the two pages.
Page1:
echo '<form action="Page2.php" method="post">',
"<input type='radio' name='Question1' value='1' onClick='disableRadio(Question1)' />",
"<input type='radio' name='Question1' value='2' onClick='disableRadio(Question1)' />",
"<input type='radio' name='Question1' value='3' onClick='disableRadio(Question1)' />",
"<div><input type='submit' value='Submit'></div>",
"</form>";
Page2:
$response=$_POST['Question1'];
echo $response;
Update to this question
When using the ReadOnly attribute, the Radio buttons in the group are still click-able. So, I decided to Disable the other Radio buttons. Is there a better solution, as I don't want the user to have the feeling that he is able to change the answer.