houssam_ballout Posted April 27, 2011 Share Posted April 27, 2011 Hello, I had 3 radio buttons with the same name, well, I had created 3 text box that are next to those 3 radio buttons. When I click save to the form, I need to know which radio button had been pressed, so that I can detect & retrieve its value. Any help? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/234909-get-value-of-radio-button/ Share on other sites More sharing options...
Pikachu2000 Posted April 27, 2011 Share Posted April 27, 2011 Post the markup for those form fields. Quote Link to comment https://forums.phpfreaks.com/topic/234909-get-value-of-radio-button/#findComment-1207218 Share on other sites More sharing options...
houssam_ballout Posted April 27, 2011 Author Share Posted April 27, 2011 Here; <td><input type="radio" name="RadioPrice1" /></td> <td>Dis 1</td> <td><input type="text" name="Dis1" /></td> <td><input type="radio" name="RadioPrice1" /></td> <td>Disc 2</td> <td><input type="text" name="Dis2" /></td> If the first radio checked, then the Dis1 box will be taken into consideration if the second radio had been checked, then the Dis2 box will be taken into consideration Thanks Quote Link to comment https://forums.phpfreaks.com/topic/234909-get-value-of-radio-button/#findComment-1207221 Share on other sites More sharing options...
JKG Posted April 27, 2011 Share Posted April 27, 2011 <td><input type="radio" name="RadioPrice1" value="1" /></td> <td>Dis 1</td> <td><input type="text" name="Dis1" /></td> <td><input type="radio" name="RadioPrice1" value="2" /></td> <td>Disc 2</td> <td><input type="text" name="Dis2" /></td> and the php: <?php if($_POST['RadioPrice1'] == 1){ //deal with Dis1 } else { //deal with Dis2 }; ?> Quote Link to comment https://forums.phpfreaks.com/topic/234909-get-value-of-radio-button/#findComment-1207232 Share on other sites More sharing options...
Pikachu2000 Posted April 27, 2011 Share Posted April 27, 2011 EDIT: JKG beat me to it . . . Quote Link to comment https://forums.phpfreaks.com/topic/234909-get-value-of-radio-button/#findComment-1207235 Share on other sites More sharing options...
JKG Posted April 27, 2011 Share Posted April 27, 2011 just doing the leg work for you Pikachu2000 thanks for linking to the PHP_SELF article btw! Quote Link to comment https://forums.phpfreaks.com/topic/234909-get-value-of-radio-button/#findComment-1207251 Share on other sites More sharing options...
houssam_ballout Posted April 28, 2011 Author Share Posted April 28, 2011 Its not working, it always gives the Dis 2 Quote Link to comment https://forums.phpfreaks.com/topic/234909-get-value-of-radio-button/#findComment-1207411 Share on other sites More sharing options...
Drummin Posted April 28, 2011 Share Posted April 28, 2011 You might be picking up some space with == 1) when value not quoted as you would around words. Try closing the gap ==1). Quote Link to comment https://forums.phpfreaks.com/topic/234909-get-value-of-radio-button/#findComment-1207420 Share on other sites More sharing options...
cyberRobot Posted April 28, 2011 Share Posted April 28, 2011 Is your <form> tag set to GET or POST? Quote Link to comment https://forums.phpfreaks.com/topic/234909-get-value-of-radio-button/#findComment-1207537 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.