• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 249
  • Last Modified:

Radio buttons in php

I've written some very basic php code that stores form inputs and displays them after the form is submitted.

For the radio buttons it just says "on". Is there any way I can display the name of the radio button that the user selected? In the html they are all the same name so the user can only select one.
1 Solution
Dave BaldwinFixer of ProblemsCommented:
The answer is yes but we don't know what you're talking about because you haven't shown us your code.  http://www.w3schools.com/html/html_forms.asp  Each radio button in a group will have the same name but a different value.  How are you receiving and displaying the button info?

You need to assign a value to each radio button in the group like this:

<input type="radio" name="test" value="1" /> Yes
<input type="radio" name="test" value="0" /> No

Kind Regards,

Loganathan NatarajanLAMP DeveloperCommented:
You can get the value using jquery easily,

ref. http://www.mkyong.com/jquery/how-to-select-a-radio-button-with-jquery/
burnedfacelessAuthor Commented:
Thanks man sorry I didn't post any script
you must need to specify value field inside radio button

if you dont write that it will return "on"

say for example

<input type="radio" name="gender" value="male" /> male
<input type="radio" name="gender" value="female" /> female

For more ref use this link :

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now