NoDoze Posted March 6, 2007 Share Posted March 6, 2007 I have an html check box that is on form page 1, and I need this info carried over onto form page 2... How do I do this? I am using php to carry the data from form page one to form page two. So far I am using: value="<?php echo $variable;?> to carry the data from form page one to form page two. How do I do the same thing, but for checkboxes? Thanks! Link to comment https://forums.phpfreaks.com/topic/41486-carry-checkbox-to-second-form-page/ Share on other sites More sharing options...
nloding Posted March 6, 2007 Share Posted March 6, 2007 If it doesn't need to be displayed, just use hidden inputs. If it needs to be displayed, there's more work, looping through the checkbox array you passed and outputting the code basically as you're already doing. If there isn't a practical reason for the user to see the information though, just use hidden inputs. Link to comment https://forums.phpfreaks.com/topic/41486-carry-checkbox-to-second-form-page/#findComment-200976 Share on other sites More sharing options...
NoDoze Posted March 6, 2007 Author Share Posted March 6, 2007 It need to be seen....How would I go about doing this? Link to comment https://forums.phpfreaks.com/topic/41486-carry-checkbox-to-second-form-page/#findComment-200978 Share on other sites More sharing options...
boo_lolly Posted March 6, 2007 Share Posted March 6, 2007 you use the $_POST method. how is the checkbox being sent to the second form? does it need to be a pre-selected checkbox, or are you printing the value or something? Link to comment https://forums.phpfreaks.com/topic/41486-carry-checkbox-to-second-form-page/#findComment-200990 Share on other sites More sharing options...
NoDoze Posted March 6, 2007 Author Share Posted March 6, 2007 form page one: <input name="solesource" type="checkbox" value="yes"> Form page 2: value="<?php echo $solesource;?>" Only on form page 2, the check does not appear...? Link to comment https://forums.phpfreaks.com/topic/41486-carry-checkbox-to-second-form-page/#findComment-200995 Share on other sites More sharing options...
NoDoze Posted March 6, 2007 Author Share Posted March 6, 2007 ok, would it make a difference if it was a radio button instead? Link to comment https://forums.phpfreaks.com/topic/41486-carry-checkbox-to-second-form-page/#findComment-201007 Share on other sites More sharing options...
NoDoze Posted March 6, 2007 Author Share Posted March 6, 2007 ok, made no difference... Can somone tell me how to get this to work? Just need the check box to be caried to the second page of the form. It posts to the database ok... Link to comment https://forums.phpfreaks.com/topic/41486-carry-checkbox-to-second-form-page/#findComment-201010 Share on other sites More sharing options...
boo_lolly Posted March 6, 2007 Share Posted March 6, 2007 form page one: <input name="solesource" type="checkbox" value="yes"> Form page 2: value="<?php echo $solesource;?>" Only on form page 2, the check does not appear...? i don't understand. you need to give more information. the checkbox doesn't appear at all? or it doesn't appear to be checked?? post more code. Link to comment https://forums.phpfreaks.com/topic/41486-carry-checkbox-to-second-form-page/#findComment-201014 Share on other sites More sharing options...
NoDoze Posted March 6, 2007 Author Share Posted March 6, 2007 When the check box is check on form one, and the variables from form one are posted via this method: ?php echo $solesource;? the check box does not appear checked on the second form page. When checked again on the second form page, then submited finally, then the data "yes" appears correctly in the database. I don't know what showing more code would help explain, but here ya go... From form 1 <FORM METHOD="POST" ACTION="form2.php"> <input name="solesource" type="radio" value="yes"> <input name="" type="reset"> <input name="add" type="submit" id="add" value="Verify Info"> </form> From form 2 <form action="/process/formprocess.php" method="post" name="form" class="form-class"> <input name="solesource" type="radio" value="<?php echo $solesource;?>"> <input type=button value="Reset" onClick="history.go(-1)"> <input name="add" type="submit" id="add" value="Submit"> </form> Just need to know how to keep the check box checked on the second form page? Thanks. Link to comment https://forums.phpfreaks.com/topic/41486-carry-checkbox-to-second-form-page/#findComment-201022 Share on other sites More sharing options...
boo_lolly Posted March 6, 2007 Share Posted March 6, 2007 you have to use the $_POST method, as i've mentioned before. btw... you can't change up the code on us like that... either keep it checkbox, or keep it radio... how are we supposed to help you if you keep changing the problem? <input name="solesource" type="radio" value="<?php echo $_POST['solesource'] ;?>"> Link to comment https://forums.phpfreaks.com/topic/41486-carry-checkbox-to-second-form-page/#findComment-201026 Share on other sites More sharing options...
pikemsu28 Posted March 6, 2007 Share Posted March 6, 2007 if you want the checkbox to be check on the second page this code needs to be included: <input name="solesource" type="radio" value="<?php echo $_POST['solesource'] ;?>" <?php if(isset($_POST['solesource'])){ echo 'selected="selected"';}?>> // the if(isset($_POST['solesource'])) statement will cause the checkbox to be checked if it was checked in the previous page. Link to comment https://forums.phpfreaks.com/topic/41486-carry-checkbox-to-second-form-page/#findComment-201033 Share on other sites More sharing options...
boo_lolly Posted March 6, 2007 Share Posted March 6, 2007 if you want the checkbox to be check on the second page this code needs to be included: <input name="solesource" type="radio" value="<?php echo $_POST['solesource'] ;?>" <?php if(isset($_POST['solesource'])){ echo 'selected="selected"';}?>> // the if(isset($_POST['solesource'])) statement will cause the checkbox to be checked if it was checked in the previous page. your code is flawed. the $_POST['solesource'] variable will be set because it exists. that doesn't mean it will have a value. you need to check to see if it has a value, not if it is set. Link to comment https://forums.phpfreaks.com/topic/41486-carry-checkbox-to-second-form-page/#findComment-201035 Share on other sites More sharing options...
NoDoze Posted March 6, 2007 Author Share Posted March 6, 2007 Hmmm...didn't work. Form #1 <FORM METHOD="POST" ACTION="form2.php"> <input name="solesource" type="checkbox" value="yes"> <input name="" type="reset"> <input name="add" type="submit" id="add" value="Verify Info"> </form> Form #2 <form action="/process/formprocess.php" method="post" name="form" class="form-class"> <input name="solesource" type="checkbox" value="<?php echo $_POST['solesource'] ;?>"> <input type=button value="Reset" onClick="history.go(-1)"> <input name="add" type="submit" id="add" value="Submit"> </form> Any ideas? Link to comment https://forums.phpfreaks.com/topic/41486-carry-checkbox-to-second-form-page/#findComment-201066 Share on other sites More sharing options...
boo_lolly Posted March 6, 2007 Share Posted March 6, 2007 you're problem is with the HTML. checkboxes aren't pre-selected like that. this is how you preselect a checkbox. <input type="checkbox" name="whatever" CHECKED> and take a look at this tutorial http://www.globalissa.com/articles/articleCheckbox.php Link to comment https://forums.phpfreaks.com/topic/41486-carry-checkbox-to-second-form-page/#findComment-201074 Share on other sites More sharing options...
sayedsohail Posted March 6, 2007 Share Posted March 6, 2007 an alternate suggestions is to use sessions. Link to comment https://forums.phpfreaks.com/topic/41486-carry-checkbox-to-second-form-page/#findComment-201077 Share on other sites More sharing options...
NoDoze Posted March 6, 2007 Author Share Posted March 6, 2007 OMG! That page is GREAT! Answered ALL my questions! Thanks again! Link to comment https://forums.phpfreaks.com/topic/41486-carry-checkbox-to-second-form-page/#findComment-201078 Share on other sites More sharing options...
pikemsu28 Posted March 6, 2007 Share Posted March 6, 2007 yeah my bad on the selected=selected part. i've been working with select boxes <input name="solesource" type="radio" value="<?php echo $_POST['solesource'] ;?>" <?php if(isset($_POST['solesource'])){ echo 'checked="checked"';}?>> my code is just testing to see if the check box has been checked. if you have multiple check boxes then you would then test the value of $_POST['solesource']. basically just trying to give a push in the right direction, not trying to give the absolute code. Link to comment https://forums.phpfreaks.com/topic/41486-carry-checkbox-to-second-form-page/#findComment-201083 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.