DBookatay Posted January 28, 2007 Share Posted January 28, 2007 How do I do this: [code]<input size="20" name="ap_nmF" value="<?php if (isset($_POST['ap_nmF'])) echo $_POST['ap_nmF']; ?>" />[/code]on a "radio" button, when all the radio buttons use the same name?[code]<input type="radio" class="radio" name="ap_bnk1" value="Apple"><input type="radio" class="radio" name="ap_bnk1" value="Grape"><input type="radio" class="radio" name="ap_bnk1" value="Orange"><input type="radio" class="radio" name="ap_bnk1" value="Pear">[/code]Any help would be apprechiated? Quote Link to comment https://forums.phpfreaks.com/topic/36013-solved-using-if-isset_postap_nmf-on-radio-buttons/ Share on other sites More sharing options...
Tandem Posted January 28, 2007 Share Posted January 28, 2007 Sorry, i'm not sure what you mean. What is the end result are you trying to achieve? Quote Link to comment https://forums.phpfreaks.com/topic/36013-solved-using-if-isset_postap_nmf-on-radio-buttons/#findComment-170846 Share on other sites More sharing options...
linuxdream Posted January 28, 2007 Share Posted January 28, 2007 Need a little more explanation... Quote Link to comment https://forums.phpfreaks.com/topic/36013-solved-using-if-isset_postap_nmf-on-radio-buttons/#findComment-170847 Share on other sites More sharing options...
bibby Posted January 28, 2007 Share Posted January 28, 2007 Do you ppl code?He's trying to get the value of his radio choice into a text field.Bookatay, what you have should work if POST['ap_nmF'] is set. Is It ?create an ELSE and see what happens.. Quote Link to comment https://forums.phpfreaks.com/topic/36013-solved-using-if-isset_postap_nmf-on-radio-buttons/#findComment-170850 Share on other sites More sharing options...
DBookatay Posted January 28, 2007 Author Share Posted January 28, 2007 I have a form, that if required fields arent inserted and error page displays telling the user to complete the required fields. Problem is that when the user clicks back to correct the problems all the data is lost. I figured out that on a text box you can use[code]<input size="20" name="ap_nmF" value="<?php if (isset($_POST['ap_nmF'])) echo $_POST['ap_nmF']; ?>" />[/code] and it will hold the information, but how do you do the same type thing on a radio button if all the radio buttons use the same name, just have different values?The page I'm working on is here. [url=http://www.carcityofdanbury.com/apply.php?applicant=single]http://www.carcityofdanbury.com/apply.php?applicant=single[/url](Hopefully my explanation helps...) Quote Link to comment https://forums.phpfreaks.com/topic/36013-solved-using-if-isset_postap_nmf-on-radio-buttons/#findComment-170856 Share on other sites More sharing options...
Tandem Posted January 28, 2007 Share Posted January 28, 2007 [quote author=bibby link=topic=124360.msg515103#msg515103 date=1169947793]Do you ppl code?He's trying to get the value of his radio choice into a text field.Bookatay, what you have should work if POST['ap_nmF'] is set. Is It ?create an ELSE and see what happens..[/quote]I like how you acted like we were morons yet you were wrong.DBookatay rather than have an error page, just have the errors appear on the same page as the form. Keep all the previously submitted info in variables and set them as the inputs values so the info is not lost. There is no need for an isset, as the input will just be blank if it isn't set. If they didn't put in a value then the box will be empty.If you mean you want the same radio button selected as the one they previously selected then make a variable for each one, and if that was the previously selected one set it as "CHECKED".e.g.[code]if ($_POST['ap_bnk'] == "Apple") {$radio1 = "CHECKED";}[/code]and put the relevant variable in the end of each radio button.E.g.[code]echo <<<HERE<input type="radio" class="radio" name="ap_bnk1" value="Apple" $radio1><input type="radio" class="radio" name="ap_bnk1" value="Grape" $radio2><input type="radio" class="radio" name="ap_bnk1" value="Orange" $radio3><input type="radio" class="radio" name="ap_bnk1" value="Pear" $radio4>HERE;[/code] Quote Link to comment https://forums.phpfreaks.com/topic/36013-solved-using-if-isset_postap_nmf-on-radio-buttons/#findComment-170866 Share on other sites More sharing options...
DBookatay Posted January 28, 2007 Author Share Posted January 28, 2007 [quote author=Tandem link=topic=124360.msg515119#msg515119 date=1169948819]I like how you acted like we were morons yet you were wrong.[/quote]My thoughts exactly...Thank you Tandem, that is what I was trying to acheve... Quote Link to comment https://forums.phpfreaks.com/topic/36013-solved-using-if-isset_postap_nmf-on-radio-buttons/#findComment-170871 Share on other sites More sharing options...
bibby Posted January 28, 2007 Share Posted January 28, 2007 meh Quote Link to comment https://forums.phpfreaks.com/topic/36013-solved-using-if-isset_postap_nmf-on-radio-buttons/#findComment-170874 Share on other sites More sharing options...
boo_lolly Posted January 28, 2007 Share Posted January 28, 2007 try this to save some space:[code]<input size="20" name="ap_nmF" value="<? ((isset($_POST['ap_nmF'])) ? $_POST['ap_nmF'] : ""); ?>" />[/code]untested. Quote Link to comment https://forums.phpfreaks.com/topic/36013-solved-using-if-isset_postap_nmf-on-radio-buttons/#findComment-170880 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.