Monday, July 30, 2012

php – Can't $_POST values from disabled Radio buttons



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;






Rating: 4 out of 5 based on 5 ratings



The post php – Can't $_POST values from disabled Radio buttons appeared first on Javascript ASK.






via Javascript ASK http://javascriptask.phpfogapp.com/php-cant-_post-values-from-disabled-radio-buttons-2.html

No comments:

Post a Comment