j.g. Posted July 27, 2007 Share Posted July 27, 2007 Hi All! I have a question regarding implementing a checkbox that DOESN'T use arrays -- everything i find when i google has arrays in it! So, I'm hoping someone here can help me come up with a solution to my problem. I have a checkbox that a user can check (default will be to have it NOT checked) - and once it's checked, to keep it checked until the user unselects it again. Here's my checkbox code: <input type ="submit" name="cv_permission" type="checkbox"> What do I have to do to keep it turned 'ON' once it's checked? Thanks for your time and help! -j.g. Quote Link to comment Share on other sites More sharing options...
DeepakJ Posted July 27, 2007 Share Posted July 27, 2007 Can you clarify. Checkboxes generally follow the behavior you just outlined. Quote Link to comment Share on other sites More sharing options...
DeepakJ Posted July 27, 2007 Share Posted July 27, 2007 Whats wrong with arrays BTW? Quote Link to comment Share on other sites More sharing options...
j.g. Posted July 27, 2007 Author Share Posted July 27, 2007 Currently, when I leave the page that the checkbox is on and then come back to it, the checkbox is gone... it's not saving it, it's clearing it out everytime.... Hope that helps! -j.g. Quote Link to comment Share on other sites More sharing options...
per1os Posted July 27, 2007 Share Posted July 27, 2007 Currently, when I leave the page that the checkbox is on and then come back to it, the checkbox is gone... it's not saving it, it's clearing it out everytime.... Hope that helps! -j.g. Well yea. You need to use sessions. Quote Link to comment Share on other sites More sharing options...
j.g. Posted July 30, 2007 Author Share Posted July 30, 2007 Hi - Thanks for the replies....I think. :-\ There's nothing wrong with arrays, I was just saying 'Without Array' since I'm only using one checkbox -> so I didn't think that an array was neccessary. But, if it is, then by all means, I can implement it with an array! As I said, I'm a Newbie to PHP, so I apologize if my question is a bit on the novice side; that's why I come to this board ... to solve problems and learn new things along the way. I'm sorry if my 'elementary question' offended anybody. frost110 mentioned using sessions... I can look into how to do this; and if anyone else has any other helpful suggestions or ideas to share and aid in my solution, I'm open to hearing them! Thanks! -j.g. Quote Link to comment Share on other sites More sharing options...
ss32 Posted July 30, 2007 Share Posted July 30, 2007 implement an array with one element for christ's sakes. anyway, when you want to get it to save, you are going to have to tell php to dynamically mark the checkbox as checked somehow. by somehow, i mean with a database or sessions or something. if it is a user preference, when the checkbox is posted store that the checkbox is true to the database. when drawing the checkbox, you can do something like this, assuming the user property is "cv_permission"... <input type="checkbox" name="cv_permission" <?php ($row['cv_permission']==true) ? echo "checked" : echo ""; ?> /> btw... in your original code you declared your checkbox as both a checkbox and a submit... not a good idea. Quote Link to comment 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.