mtd
06-21-2005, 10:13 PM
Yes, this does involve some javascript, but I think the overall issue is PHP. Please correct me if I'm wrong.
I have a multipart form (all on the same page, just not displayed all at once), and I navigate between parts like so:foreach($_POST as $key => $value) {
$_SESSION[$pageSectionName[$_SESSION[page]]][$key] = $value;
}
// Stores form data in Session
// FYI, $pageSectionName is an array that stores the name of
// each section, used to display the correct section
if($_POST[goTo] == '<<<') $_SESSION[page]--;
if($_POST[goTo] == '>>>') $_SESSION[page]++;
// REST OF CODE.....
echo '<input name="goTo" type="submit" value="<<<">';
echo '<input name="goTo" type="submit" value=">>>">';
// $_SESSION[page] determines what part to show (obviously
// there is more code than what is listed here, but it is not relevant
// to this issue. If you need it, please ask, but be warned - it is quite large.
Ok, so far, so good. Everything works. Now, I need to implement a link submit system to jump to any page, not just consecutive pages like above (although I still need the above code). So, I add:if(isset($jump)) {
$_SESSION[page] = $jump;
unset($jump);
}
for($i = 1; $i < count($pageSectionName); $i++) {
echo '<a href="order.php?jump='.$i.'" onClick="document.forms["the_form"].submit();return false;">'.$i.'</a> ';
}
That works, too. HOWEVER, when the links are used to navigate, any values within the form (<input> etc.) are not saved in the session. Does anyone see a way around this? Even though it is JS, there's got to be some way to save to a PHP session... I'm thinking some kind of hidden <input>, but that may be way off track?
I have a multipart form (all on the same page, just not displayed all at once), and I navigate between parts like so:foreach($_POST as $key => $value) {
$_SESSION[$pageSectionName[$_SESSION[page]]][$key] = $value;
}
// Stores form data in Session
// FYI, $pageSectionName is an array that stores the name of
// each section, used to display the correct section
if($_POST[goTo] == '<<<') $_SESSION[page]--;
if($_POST[goTo] == '>>>') $_SESSION[page]++;
// REST OF CODE.....
echo '<input name="goTo" type="submit" value="<<<">';
echo '<input name="goTo" type="submit" value=">>>">';
// $_SESSION[page] determines what part to show (obviously
// there is more code than what is listed here, but it is not relevant
// to this issue. If you need it, please ask, but be warned - it is quite large.
Ok, so far, so good. Everything works. Now, I need to implement a link submit system to jump to any page, not just consecutive pages like above (although I still need the above code). So, I add:if(isset($jump)) {
$_SESSION[page] = $jump;
unset($jump);
}
for($i = 1; $i < count($pageSectionName); $i++) {
echo '<a href="order.php?jump='.$i.'" onClick="document.forms["the_form"].submit();return false;">'.$i.'</a> ';
}
That works, too. HOWEVER, when the links are used to navigate, any values within the form (<input> etc.) are not saved in the session. Does anyone see a way around this? Even though it is JS, there's got to be some way to save to a PHP session... I'm thinking some kind of hidden <input>, but that may be way off track?