saving array values between pages?

G

Geoff Cox

Hello,

I have a series of pages each of which creates an array of values.

How do I keep all the array values until the last page?

Cheers

Geoff
 
M

Mick White

Geoff said:
Hello,

I have a series of pages each of which creates an array of values.

How do I keep all the array values until the last page?


What do *you* mean by an "array of values"? Example, please.

Mick
 
G

Geoff Cox

What do *you* mean by an "array of values"? Example, please.

Mick,

The first page will have

array1[0] to array1[7] values

and the second

array2[0] to array2[7] values

etc etc

and I want to have all these sets available on the last page...

Incidentally it would probably make life easier if I could have all
these arrays populated on the same page. At the moment I am having
trouble seeing how to do this. Is it possible to create a table in the
body of the page and use Javascipt to put a series of questions etc
into particular cells?

Cheers

Geoff
 
M

Mick White

Geoff said:
What do *you* mean by an "array of values"? Example, please.

The first page will have
array1[0] to array1[7] values
and the second array2[0] to array2[7] values etc etc.
and I want to have all these sets available on the last page...

Store the array in a hidden form element.

onsubmit='this.form.hiddenFieldName.value=array1.join("*")'
// use a separator that will not appear in the array entries (*)

When you submit the form to page 2, the array values will be available
as a string as part of the "get" query, or as part of the "post" info.
What server-side language are you using?
You can use javascript if you want by parsing the query string.


if(location.search){
vals= unescape((location.search.substring(1).replace(/\+/g,""))).split("&");
for(i=0;i<vals.length;i++){
vals=vals.split("=")
window[vals[0]]=vals[1]
}

Now the array values are available as the global variable <hiddenFieldName>
Mick
 
G

Geoff Cox

Store the array in a hidden form element.

onsubmit='this.form.hiddenFieldName.value=array1.join("*")'
// use a separator that will not appear in the array entries (*)

When you submit the form to page 2, the array values will be available
as a string as part of the "get" query, or as part of the "post" info.
What server-side language are you using?
You can use javascript if you want by parsing the query string.


if(location.search){
vals= unescape((location.search.substring(1).replace(/\+/g,""))).split("&");
for(i=0;i<vals.length;i++){
vals=vals.split("=")
window[vals[0]]=vals[1]
}

Now the array values are available as the global variable <hiddenFieldName>
Mick


Many thanks Mick - will read with care in the morning - need some
sleep now!

Cheers

Geoff
 
G

Geoff Cox

Another way could be a big <iframe> that fills the page , letting the
different pages displayed in the iframe store their arrays in the parent
document.

I think I am going back to the idea of keeping all the action in one
page!

Cheers

Geoff
 
G

Geoff Cox

On Tue, 13 Sep 2005 08:14:37 GMT, "Zoe Brown"

Zoe,

Many thanks for the detailed answer. Great!

Cheers

Geoff
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,430
Messages
2,571,676
Members
48,796
Latest member
Greg L.

Latest Threads

Top