jaArch Posted October 12, 2011 Share Posted October 12, 2011 Hi: Is this the correct way to do a memory form for a checkbox? <input name="status[]" id="pending" value="<?=$_POST['pending'] ?>" type="checkbox" /> Quote Link to comment https://forums.phpfreaks.com/topic/248940-memory-form-checkbox/ Share on other sites More sharing options...
codefossa Posted October 12, 2011 Share Posted October 12, 2011 If you're posting to that page, but you could use session and only have to post once at the end of the form. Also, you shouldn't use short tags. value="<?php echo $_POST['pending']; ?>" You're just a little off. You gotta echo the variable, and you should use delimiter. Quote Link to comment https://forums.phpfreaks.com/topic/248940-memory-form-checkbox/#findComment-1278450 Share on other sites More sharing options...
jaArch Posted October 12, 2011 Author Share Posted October 12, 2011 Why delimiter? How's that done? Quote Link to comment https://forums.phpfreaks.com/topic/248940-memory-form-checkbox/#findComment-1278451 Share on other sites More sharing options...
jcbones Posted October 12, 2011 Share Posted October 12, 2011 delimiter being talked about is the semi-colon after your variable. And, you are echo'ing it, but judging from your post, you are wanting to know how to remember it's checked state. 1. A checkbox is either on or off. 2. You shouldn't use short tags, as it is being removed, and is not very portable. 3. You need to use the POST array to set the checked value. 4. You need to know which checkbox you are inquiring about, so use indexes. Example <input name="status[1]" id="pending" value="Shouldn't be a POST variable" <?php if(isset($_POST['status'][1])) echo 'checked'; ?> /> Quote Link to comment https://forums.phpfreaks.com/topic/248940-memory-form-checkbox/#findComment-1278454 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.