用javascript发回

I have an order list on "Page1", I used javascript to write orders into html div (when user clicked add button, item added to the list). Then I posted all values to the next page "Page2" if user clicks confirm button. I need to show the same list when user get backed from Page2 to Page1 for instance to add another item. The problem is I'm using javascript to generate order list, so I can not post back. Is it impossible to find a solution with javascript or I have to change code that generate order list from client side to php?

You could save the data in $_COOKIE\$_SESSION before sending them to the page 2...

You could serialize your form with serialize()

  • Well one way to achieve this is in the same javascript, store the values in an array while redirecting to page 2. And when you go back to page 1, use the values from array to show the list items that had been selected. This is a bit complex way to play with arrays.
  • Second option is to use Database. Store the values in database on confirmation from page 1. Again when you go back to page 2, first check values in database and display them in selected list as according to your requirement.