By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,230 Members | 2,427 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,230 IT Pros & Developers. It's quick & easy.

saving array values between pages?

P: n/a
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
Sep 12 '05 #1
Share this Question
Share on Google+
10 Replies


P: n/a
Geoff Cox wrote:
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
Sep 12 '05 #2

P: n/a
Geoff Cox wrote:
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?


One could convert those arrays to and from a string
and stash the string in a cookie.

--
--.
--=<> Dr. Clue (A.K.A. Ian A. Storms) <>=-- C++,HTML, CSS,Javascript
--=<> http://resume.drclue.net <>=-- AJAX, SOAP, XML, HTTP
--=<> http://www.drclue.net <>=-- SERVLETS,TCP/IP, SQL
--.
Sep 12 '05 #3

P: n/a
On Mon, 12 Sep 2005 21:09:52 GMT, Mick White
<mw***********@rochester.rr.com> wrote:
Geoff Cox wrote:
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,

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





Mick


Sep 12 '05 #4

P: n/a
On Mon, 12 Sep 2005 21:15:00 GMT, Dr Clue <ia*********@mindspring.com>
wrote:
Geoff Cox wrote:
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?


One could convert those arrays to and from a string
and stash the string in a cookie.


Hello,

any other way?

Cheers

Geoff
Sep 12 '05 #5

P: n/a
Geoff Cox wrote:
On Mon, 12 Sep 2005 21:09:52 GMT, Mick White wrote:
Geoff Cox wrote:
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.


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.j oin("*")'
// 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[i]=vals[i].split("=")
window[vals[i][0]]=vals[i][1]
}

Now the array values are available as the global variable <hiddenFieldName>
Mick
Sep 12 '05 #6

P: n/a
Geoff Cox wrote:
On Mon, 12 Sep 2005 21:15:00 GMT, Dr Clue <ia*********@mindspring.com>
wrote:
Geoff Cox wrote:
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?

One could convert those arrays to and from a string
and stash the string in a cookie.


any other way?


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.

--
--.
--=<> Dr. Clue (A.K.A. Ian A. Storms) <>=-- C++,HTML, CSS,Javascript
--=<> http://resume.drclue.net <>=-- AJAX, SOAP, XML, HTTP
--=<> http://www.drclue.net <>=-- SERVLETS,TCP/IP, SQL
--.
Sep 12 '05 #7

P: n/a
On Mon, 12 Sep 2005 22:24:43 GMT, Mick White
<mw***********@rochester.rr.com> wrote:
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[i]=vals[i].split("=")
window[vals[i][0]]=vals[i][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

Sep 12 '05 #8

P: n/a
On Mon, 12 Sep 2005 22:33:41 GMT, Dr Clue <ia*********@mindspring.com>
wrote:
Geoff Cox wrote:
On Mon, 12 Sep 2005 21:15:00 GMT, Dr Clue <ia*********@mindspring.com>
wrote:
Geoff Cox wrote:
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?
One could convert those arrays to and from a string
and stash the string in a cookie.


any other way?


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

Sep 12 '05 #9

P: n/a

"Geoff Cox" <ge*******@notquitecorrectfreeuk.com> wrote in message
news:cj********************************@4ax.com...
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


you could
1) use a session
2) store in a cookie
3) pass all the variables from one page to the next via a get or post, each
page accumulating the values for the next page.
4) Create a hidden iframe which has some javascript which holds all these
values.
5) Create a non hidden iframe (like a menu or something else) that does not
get reloaded and store the values there.
6) forget it and as per your other post keep all the action on the same
page.

I actually prefer option 4, followed by 6.

Keeping the action on the same page just means that you need to (bearing in
mind I do not have 100% clear idea of what you are doing)

1) create all the arrays.
2) display the series of questions on the page (I think you wanted one as a
time)
3) store the answers in your arrays
4) post these value to your server.

I think in a seperate post you asked how to display the questions one after
the other ?

you beed a div which is used to display the question. When th euser has
answered the question (click a button i presume) you use innerHTML to
display the next question. or you could display "all" the questions in a
table and then just hide all the unwanted questions.

Sorry for the fragmented answer if there is anything you want some more
details on please just ask !!

Zoe
Sep 13 '05 #10

P: n/a
On Tue, 13 Sep 2005 08:14:37 GMT, "Zoe Brown"
<zo***********@N-O-S-P-A-A-Mtesco.net> wrote:

Zoe,

Many thanks for the detailed answer. Great!

Cheers

Geoff
you could
1) use a session
2) store in a cookie
3) pass all the variables from one page to the next via a get or post, each
page accumulating the values for the next page.
4) Create a hidden iframe which has some javascript which holds all these
values.
5) Create a non hidden iframe (like a menu or something else) that does not
get reloaded and store the values there.
6) forget it and as per your other post keep all the action on the same
page.

I actually prefer option 4, followed by 6.

Keeping the action on the same page just means that you need to (bearing in
mind I do not have 100% clear idea of what you are doing)

1) create all the arrays.
2) display the series of questions on the page (I think you wanted one as a
time)
3) store the answers in your arrays
4) post these value to your server.

I think in a seperate post you asked how to display the questions one after
the other ?

you beed a div which is used to display the question. When th euser has
answered the question (click a button i presume) you use innerHTML to
display the next question. or you could display "all" the questions in a
table and then just hide all the unwanted questions.

Sorry for the fragmented answer if there is anything you want some more
details on please just ask !!

Zoe


Sep 13 '05 #11

This discussion thread is closed

Replies have been disabled for this discussion.