Forum Moderators: open

Message Too Old, No Replies

Passing values between pages

         

webmannw

3:44 pm on Aug 10, 2005 (gmt 0)

10+ Year Member



Hi all, woder if you could help.

I am doing a seties of short tutorials and need to pass answer values from a form to a javascript function which then displays answers in a results page based on those choosen by the user. The function I'm using passes the answer values to the URL and then parse them into an array from which a switch statement sorts out which answer to print to screen. WOrkd fine so far.

NOw the client asks if the values can be held for a couple more pages of questions and the answers all printed to screen together at the end.

Does anyone have any ideas how best to do this?

This is that I'm using to get the values in to the URL:

(lo3 id the id on the dropdown selected)

lot3=document.getElementById ("lo3").value;window.location ="less_obs_answers1.htm?lo3="+lot3

garann

7:02 pm on Aug 10, 2005 (gmt 0)

10+ Year Member



Other than adding all the answers from all the pages to the querystring, like you're doing already, you can't do this with Javascript. A nice server side scripting language which exposes some kind of Session object for your use could track your user's answers very easily.

webmannw

9:50 pm on Aug 10, 2005 (gmt 0)

10+ Year Member



Thanks for the reply.

Any ideas how I can take the first url string, add the second set of values and pass the whole thing to a 3rd page?

Thanks

garann

8:56 pm on Aug 11, 2005 (gmt 0)

10+ Year Member



Sure. You can use the location.search object to get all the values passed to a page in the querystring. So in building links from the second page to the next page, you'd use something like


document.getElementById("myLink").href =
"nextPage.html?" + window.location.search + "&param14=" + param14 +
"&param15=" + param15;