I am building a survey system. I have a page containing 10 items, each item has yes/no options to select. Something like this:
Yes No
1. o o
2. o o
...
<submit>
When I hit submit button, I want to know which items have been selected to yes and no. How can I do that? Thanks.
I know how to retrieve radio button value by name, my question is how to get buttons whose selected value is "yes" and "no". I kinda know how to do it in javascript, but I am not sure how to pass the javascript value back to the PHP script.
If you have something like this
<input type="radio" value="1'"name="radbut">Yes
<input type="radio" value="2" name="radbut">No
the php to select the selected value is like this
$selected=$_GET["radbut"];
I will go into a detailed explanation.
<input type="radio" name="option1" value="Yes"> Yes
<input type="radio" name="option1" value="No"> No
When you're processing this via PHP, there will only be a single "option1" posted value. It will either be Yes, or No, based on which input the user selected.
echo "The user selected: ".$_POST['option1'];
If yes, the above will return:
The user selected: Yes
Same goes for the No.