jrapin Posted November 16, 2006 Share Posted November 16, 2006 I'm working on a fillable form that uses text and checkboxes to submit info.The text boxes work, but I can't seem to get the checkboxes to print.What makes it difficult for me is: I want the user to have the option of selecting from various boxes and simply mark the one(s) they choose. So I need to indicate "if checked print?"Please help.[attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/27483-php-checkbox-printing/ Share on other sites More sharing options...
Psycho Posted November 16, 2006 Share Posted November 16, 2006 Are you giving the checkboxes "values"?Also ONLY checboxes that are checked will be passed in the POST variables. So, checkboxes that are not checked are not sent. Link to comment https://forums.phpfreaks.com/topic/27483-php-checkbox-printing/#findComment-125668 Share on other sites More sharing options...
jrapin Posted November 16, 2006 Author Share Posted November 16, 2006 I would like to, but I'm confused as to contrasting them with the requred text fields.The items in question are referred to as fruits in my document. Could someone check out the attached file and determine what changes are necessary to allow this form still require, print and send form to e-mail while sending the fruits ONLY if checked? Link to comment https://forums.phpfreaks.com/topic/27483-php-checkbox-printing/#findComment-125690 Share on other sites More sharing options...
Orio Posted November 16, 2006 Share Posted November 16, 2006 To test if a checkbox was checked, use:[code]<?phpif(isset($_POST['checkbox_name_here'])) echo "Checked";?>[/code]Orio. Link to comment https://forums.phpfreaks.com/topic/27483-php-checkbox-printing/#findComment-125692 Share on other sites More sharing options...
jrapin Posted November 16, 2006 Author Share Posted November 16, 2006 Thanks Orio, check out the document attached to my initial message - to see where I have placed the code you have provided me on this glorious day!Do I still have to assign each box a value? Link to comment https://forums.phpfreaks.com/topic/27483-php-checkbox-printing/#findComment-125701 Share on other sites More sharing options...
Orio Posted November 16, 2006 Share Posted November 16, 2006 Yes that's correct.If you want to shorten it, use:[code]<?php$checkboxes = array("apples", "oranges", "grapes", "pears"); //you can add remove valuesforeach ($checkboxes as $checkbox){ if(isset($_POST[$checkbox])) echo $checkbox." is checked";}?>[/code]Orio. Link to comment https://forums.phpfreaks.com/topic/27483-php-checkbox-printing/#findComment-125706 Share on other sites More sharing options...
jrapin Posted November 16, 2006 Author Share Posted November 16, 2006 Thanks Sir! Link to comment https://forums.phpfreaks.com/topic/27483-php-checkbox-printing/#findComment-125742 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.