shock Posted June 11, 2007 Share Posted June 11, 2007 Hi, I am creating an email form with checkbox included. And I need the checkbox to be ticket when I enter the form though links. IE List of checkbox's checkbox 1 checkbox 2 checkbox 3 checkbox 4 say I was another page and I click on a link (call the link checkbox 1) I would like the checkbox to be ticked automatically. I know this makes no sense but I hope you get the idea. Thanks in advance. Lee Quote Link to comment https://forums.phpfreaks.com/topic/55062-checkbox-question/ Share on other sites More sharing options...
kathas Posted June 11, 2007 Share Posted June 11, 2007 You need the checked="checked" attribute of the HTML <input /> tag... you could do sth like this... if i understand what you need... <?php if ($_GET['checkbox1'] == "check") { $check1 = ' checked="checked" '; } echo '<input type="checkbox" name="name" value="value"'.$check1.'/>'; ?> any variation to make the above code more effective is what you need, especially if you have more checkboxes but i guess you get the point... this is it more or less... Quote Link to comment https://forums.phpfreaks.com/topic/55062-checkbox-question/#findComment-272201 Share on other sites More sharing options...
shock Posted June 11, 2007 Author Share Posted June 11, 2007 Thanks for the reply, but it's not really what I am after because all checkboxs will be on one page, I don't really want to create a number of them. Could do with something like mail.php?check=1 for checkbox 1 or something. Quote Link to comment https://forums.phpfreaks.com/topic/55062-checkbox-question/#findComment-272204 Share on other sites More sharing options...
kathas Posted June 11, 2007 Share Posted June 11, 2007 that is what i am saying in my post... you just have to add checked="checked" to the checkbox you want checked. if you want to do it using $_GET vars you should check the vars if (isset($_GET['check'])) { switch($_GET['check']) { case 1: $check1 = ' checked="checked" '; case 2: $check2 = ' checked="checked" '; } } i hope i am understandable now... Quote Link to comment https://forums.phpfreaks.com/topic/55062-checkbox-question/#findComment-272211 Share on other sites More sharing options...
shock Posted June 11, 2007 Author Share Posted June 11, 2007 ahh sorry did not see that, not with it today lol. Thanks for your help I will try that out. Quote Link to comment https://forums.phpfreaks.com/topic/55062-checkbox-question/#findComment-272219 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.