Retaining radio button value of a form after postingPeriod or radio buttons are used where the visitor has to make selection out of some given choice. The user can only make one choice out of the given options. So radio buttons are grouped in a common choice and one of them is selected by the user. The difference between radio button and check box is user can make multiple selections in case of check boxes.
A group of radio buttons will have common name and different values. Here to retain the value of the radio buttons we have to read the value of the button. We will use header redirection to post back the value of the period button to the main page or the page where form is used. Once the member makes a selection and submits the form, the data posted to another page name pb-prdck.php and post it back to our main page using redirection. Here we assumed that all form validation is failed so we are posting back the data. Here is the code to display the form, note that we have used one unique variable for each period button and the variables gets their values from a switch command which check value of the period button and accordingly set and reset the variables. Here is the code of the form with decode script.
Here is the code for pb-prdck.php file
This article is written by plus2net.com team.
|▼ Web Forms & handling data in PHP|