Thauwa Posted April 3, 2009 Share Posted April 3, 2009 I need the user to select only one radio button out of a group of four radios. I have two groups of four buttoned radios. How can this be achieved? Thanks in advance! Quote Link to comment https://forums.phpfreaks.com/topic/152366-single-radio-button-selection-per-group/ Share on other sites More sharing options...
Yesideez Posted April 3, 2009 Share Posted April 3, 2009 Give them all the same name but different values: <input type="radio" name="myrad" value="1" /> <input type="radio" name="myrad" value="2" /> <input type="radio" name="myrad" value="3" /> <input type="radio" name="myrad" value="4" /> To read: $chosen=$_POST['myrad']; Quote Link to comment https://forums.phpfreaks.com/topic/152366-single-radio-button-selection-per-group/#findComment-800264 Share on other sites More sharing options...
Thauwa Posted April 4, 2009 Author Share Posted April 4, 2009 Thanks for the help, it worked, but.... What if there are no values, due to inserting purposes? I mean, how do I insert a value into MySql from the radio button, like 'y' if the button is selected and 'n' for the rest? Quote Link to comment https://forums.phpfreaks.com/topic/152366-single-radio-button-selection-per-group/#findComment-801184 Share on other sites More sharing options...
Yesideez Posted April 4, 2009 Share Posted April 4, 2009 Just store the button number in the database as you can see by reading the data which ones weren't selected! No need to store "y" or "n" for the state of the radio buttons as only one radio button can be selected at any one time. Quote Link to comment https://forums.phpfreaks.com/topic/152366-single-radio-button-selection-per-group/#findComment-801406 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.