dumdumsareyum Posted July 6, 2009 Share Posted July 6, 2009 Not sure whether to post this in PHP or Javascript. I have a form that is being submitted when another form is submitted using javascript. <form action="out_detail.php" method="post" enctype="multipart/form-data" onsubmit="javascript:submitdetail()" > Where submitdetail looks like: function submitdetail() { document.forms.detail_form.submit(); } The problem I'm having is I'm not sure how to capture the information that is submitted from the first form before the second form submits. I tried setting a session variable at the very beginning of page for the value I'm looking for: if($_POST[detail_descrip]) { $_SESSION[add_out][detail_descrip] = $_POST[detail_descrip]; } but the info is not showing up in the session variable, like the page doesn't load or something in between form submissions for the value to be set? Help please. Quote Link to comment https://forums.phpfreaks.com/topic/164972-solved-php-javascript-form-values/ Share on other sites More sharing options...
Philip Posted July 6, 2009 Share Posted July 6, 2009 I spot some problems with your php, but it shouldn't break it: if($_POST[detail_descrip]) { $_SESSION[add_out][detail_descrip] = $_POST[detail_descrip]; } You need session_start() and make sure to use quotes around the key names (unless you defined a constant with that name). Otherwise it'll throw a notice. <?php session_start(); if($_POST['detail_descrip']) { $_SESSION['add_out']['detail_descrip'] = $_POST['detail_descrip']; } Quote Link to comment https://forums.phpfreaks.com/topic/164972-solved-php-javascript-form-values/#findComment-869886 Share on other sites More sharing options...
dumdumsareyum Posted July 6, 2009 Author Share Posted July 6, 2009 I do have a session start (just didn't show here) and I know that my other session variables I am setting are working when I'm not using javascript to submit a form prior to submitting the form that was clicked on. Thanks for the warning on the array keys though, it hasn't given me an issue so far but good to know. I have several separate forms with submit buttons on the page, but I want one specific form submitted everytime another form on the page is submitted. So also if anyone has suggestions of another way to do this they'd be appreciated to Quote Link to comment https://forums.phpfreaks.com/topic/164972-solved-php-javascript-form-values/#findComment-869890 Share on other sites More sharing options...
dumdumsareyum Posted July 6, 2009 Author Share Posted July 6, 2009 Well, i figured out a way to combine the forms without the need for the javascript submit, but in doing so I realized i had a typo for one of my variables in several places, so that was probably the root of the problem. Thanks anyway! Quote Link to comment https://forums.phpfreaks.com/topic/164972-solved-php-javascript-form-values/#findComment-869913 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.