PDA

View Full Version : Forms and the POST method



yhgtbfk
28 May 2006, 08:07 PM
Hi guys.

I have searched and searched and searched and I can't seem to find a solution to what may be a simple problem.

I have two web pages - quiz and results.

I want to pass the information from the quiz page to the results page using the post method.

Then on the results page I need javascript code (I dont have a server) to access the information passed from the quiz form.

For example. There is a textbox called username.

What is the syntax for accessing the value of username from the results page?

Please please please help me.

Kind Regards
Y

Rincewind
29 May 2006, 11:45 AM
You can't is the short answer. The post method sends the variables as part of the http request headers. The server does not return the headers so the variables are not returned.

You can use the get method to send since the variables are still in the query string of the URL. But a more private method might be to set the variables to a cookie. Then the new page can read from the cookie.

The most correct way is don't actually submit the form at all. When they click submit, run the form validation/marking script imediately (include the script with the first page) then use a Alert to popup the score. When they click OK, they can be diverted to a try again or congratulations page of your choice. Since the page never has to reload, you don't have to pass the variables using any method at all.