lovelf Posted November 5, 2008 Share Posted November 5, 2008 I want to be able to have some of the checkboxes in my form already checked only if the user comes from a certain link to the form page. example: http://www.url.com/form.php?check11=checked or http://www.url.com/form.php?check11=checked&check7=checked two different links from previous pages that would automatically check a checkbox. I have no clue how to make this work. Link to comment https://forums.phpfreaks.com/topic/131461-is-it-possible-to-check-a-checkbox-from-the-url/ Share on other sites More sharing options...
lovelf Posted November 5, 2008 Author Share Posted November 5, 2008 Somebody helped me with this code which works great but I need to make it work inside an iframe.. <input type="checkbox" name="foo" <?php if($_GET['check11'] == "checked") echo "checked=\"checked\""; ?> /> how would it be? pagecontainingiframeurl?form.php?check11=checked ?? Link to comment https://forums.phpfreaks.com/topic/131461-is-it-possible-to-check-a-checkbox-from-the-url/#findComment-682750 Share on other sites More sharing options...
lovelf Posted November 5, 2008 Author Share Posted November 5, 2008 ok. I got it.. and it works great. <? if($_GET['db'] == "y") echo <<<html <iframe frameborder=0 width=780px height=650px src=http://www.siteurl/contactb.php?check11=checked></iframe> html; ?> <? if($_GET['db'] == "n") echo <<<html <iframe frameborder=0 width=780px height=650px src=http://www.siteurl/contactb.php?check12=checked></iframe> html; ?> <? if($_GET['db'] == "r") echo <<<html <iframe frameborder=0 width=780px height=650px src=http://www.siteurl/contactb.php?check11=checked&check12=checked></iframe> html; ?> <? if($_GET['db'] == "z") echo <<<html <iframe frameborder=0 width=780px height=650px src=http://www.siteurl/contactb.php></iframe> html; ?> One final question, could I set the "db=z" as a default to be shown in case there is no db=y , n , or r in the URL? Link to comment https://forums.phpfreaks.com/topic/131461-is-it-possible-to-check-a-checkbox-from-the-url/#findComment-682792 Share on other sites More sharing options...
lovelf Posted November 5, 2008 Author Share Posted November 5, 2008 using the switch method. Link to comment https://forums.phpfreaks.com/topic/131461-is-it-possible-to-check-a-checkbox-from-the-url/#findComment-682971 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.