View Full Version : Forwarding form results, please help...

07-15-2004, 04:08 PM
I'm very new to javascript, so I hope someone here will know the answer to this.

I'm trying to create a mock-commercial site for a school project and I'm getting stuck on one point. I have a page with selection boxes which 'get' to a javascript to create a results page. On the result page it echos back the answers from the selection box and has the standard textboxes for the user to then enter name/address/creditcard information. That form forwards to a final page with displays the name/address stuff perfectly, but it just says undefined for the information that was passed from the first page to the second page.

Is there a way to redeclare those values and forward them on to the last page with the new information?

07-15-2004, 07:02 PM
To be honest, I'm not even sure how you're passing the values from the first page to the second using Javascript! (Unless you're talking about server-side Javascript, so ASP...)

If you've got two different pages, and you've got a form on the first and you post the form to the second page, that means you're sending the form variables to the server AND requesting the second page from the server.

Since the form variables and the second page are on the server for a few moments, you'll need a server-side language to create a script to store those previous values onto this page. You can't use a client-side language as it's too late at that point.

I've done exactly what you're talking about using PHP and the following script:

The only other way if you insist on using client-side Javascript is to combine the 3 pages into 1 page and separate the 3 pages into 3 DIVs and global variables to store the values. At first, only the first DIV would be visible, the other two hidden (using CSS). When they press the 'next' button, the first DIV would hide itself and the second DIV would become visible; and so on. This makes for uglier code, but it does the trick. There are other variations on this method, but that's the idea.

Hope that helps,

Vincent Puglia
07-15-2004, 10:26 PM

The following:

explains the various methods you can use to pass data from one page to another via javascript.

If, after reading it, you still have trouble, post the relevant code.