verdure Posted August 20, 2008 Share Posted August 20, 2008 Hi I have a registration form with form validations for some text fields. the form also have some check boxes and radio buttons. On submission of the form the validations are checked in formvalidation.php file. and error messages are sent back to the registration page. In this process i am unable to retain the values of checkbox or radio button submitted first. Could somebody please direct as to how to retain values of checkbox/ radio buttons. Thank you Quote Link to comment https://forums.phpfreaks.com/topic/120513-how-to-retain-checkbox-values/ Share on other sites More sharing options...
budimir Posted August 20, 2008 Share Posted August 20, 2008 Try to google for "sticky forms", that will help you! Quote Link to comment https://forums.phpfreaks.com/topic/120513-how-to-retain-checkbox-values/#findComment-621007 Share on other sites More sharing options...
Jibberish Posted August 20, 2008 Share Posted August 20, 2008 one way that i sometimes do this is <form action="#" method="POST"> <input <?php if ($_POST['dog'] == 'checked') { echo 'checked ';} ?> type="checkbox" name="dog" value="checked" /> <input <?php if ($_POST['cat'] == 'checked') { echo 'checked ';} ?> type="checkbox" name="cat" value="checked" /> <input <?php if ($_POST['frog'] == 'checked') { echo 'checked ';} ?> type="checkbox" name="frog" value="checked" /> <input type="submit" value="submit"> </form> this form just links to the same page, but basically if one of the inputs is checked the value of $_POST['dog'] will be whatever is in the value ("checked in that case) in the html tag (with the name "dog"). So i just check for that and if its true, echo checked into the form. Quote Link to comment https://forums.phpfreaks.com/topic/120513-how-to-retain-checkbox-values/#findComment-621020 Share on other sites More sharing options...
verdure Posted August 20, 2008 Author Share Posted August 20, 2008 thank you for the suggestions .. i will take it forward from here ! Quote Link to comment https://forums.phpfreaks.com/topic/120513-how-to-retain-checkbox-values/#findComment-621025 Share on other sites More sharing options...
MasterACE14 Posted August 20, 2008 Share Posted August 20, 2008 you can also use Session variables to retain the values. Quote Link to comment https://forums.phpfreaks.com/topic/120513-how-to-retain-checkbox-values/#findComment-621029 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.