ilikephp Posted May 20, 2009 Share Posted May 20, 2009 hello all!! How can I force the checkbox no to be erased? I am using this code below but it is not working <input name="topic1" type="checkbox" id="topic1" value="<?php if (isset($_POST['VB.NET'])) echo $_POST['VB.NET']; ?>" /> Link to comment https://forums.phpfreaks.com/topic/158916-solved-checkbox/ Share on other sites More sharing options...
irvieto Posted May 20, 2009 Share Posted May 20, 2009 Hi. I do not understand the question. What do you mean with erase the checkbox? Link to comment https://forums.phpfreaks.com/topic/158916-solved-checkbox/#findComment-838121 Share on other sites More sharing options...
GingerRobot Posted May 20, 2009 Share Posted May 20, 2009 In order for a checkbox to be ticked, you don't set it's value, you set checked="checked". You might like to check out my tutorial on checkboxes and databases: http://www.phpfreaks.com/tutorial/working-with-checkboxes-and-a-database Link to comment https://forums.phpfreaks.com/topic/158916-solved-checkbox/#findComment-838125 Share on other sites More sharing options...
ilikephp Posted May 20, 2009 Author Share Posted May 20, 2009 Sorry for not clarifiying! I meant that for the field name: when I enter a name, and I click submit or accept, I need to see my form again, so the names are not erased because I put: <input type="text" name="name" value="<?php if (isset($_POST['name'])) echo $_POST['name']; ?>"> I need to do the same for the checkboxes. Link to comment https://forums.phpfreaks.com/topic/158916-solved-checkbox/#findComment-838128 Share on other sites More sharing options...
GingerRobot Posted May 20, 2009 Share Posted May 20, 2009 In order for a checkbox to be ticked, you don't set it's value, you set checked="checked". You might like to check out my tutorial on checkboxes and databases: http://www.phpfreaks.com/tutorial/working-with-checkboxes-and-a-database Link to comment https://forums.phpfreaks.com/topic/158916-solved-checkbox/#findComment-838157 Share on other sites More sharing options...
ilikephp Posted May 20, 2009 Author Share Posted May 20, 2009 thx for the link, it is well organised and easy to understand; but I did not find a solution to my problem :S I am adding this script below for the fields, what should I add for the checkboxes? value="<?php if (isset($_POST['name'])) echo $_POST['name']; ?> Link to comment https://forums.phpfreaks.com/topic/158916-solved-checkbox/#findComment-838208 Share on other sites More sharing options...
GingerRobot Posted May 20, 2009 Share Posted May 20, 2009 Ok. So you know how to make a checkbox ticked by default, right? You also know how to check to see if it was checked in the POST array, right? So...What do you think you need to do? Link to comment https://forums.phpfreaks.com/topic/158916-solved-checkbox/#findComment-838265 Share on other sites More sharing options...
Masna Posted May 20, 2009 Share Posted May 20, 2009 <input name="topic1" type="checkbox" id="topic1"<?PHP echo (!empty($_POST['topic1']))?" checked=\"checked\"":NULL; ?>> Link to comment https://forums.phpfreaks.com/topic/158916-solved-checkbox/#findComment-838266 Share on other sites More sharing options...
ilikephp Posted May 21, 2009 Author Share Posted May 21, 2009 THx a lot (y) Link to comment https://forums.phpfreaks.com/topic/158916-solved-checkbox/#findComment-838746 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.