Welcome, Guest
Username: Password: Remember me

TOPIC: Javascript - global, persistent array

Javascript - global, persistent array 2 years 11 months ago #64347

  • doodsonj
  • doodsonj's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 30
  • Thank you received: 2
  • Karma: 2
Hi all,

Hope you're having a good day/evening.

I'm writing a script at the moment and I'm looking to create a global array that can be used, updated, etc across a few pages of the questionnaire.

Has anybody done this? Or know how I might achieve this?

I guess the browser clears variables between each page.

Thanks, J.
The administrator has disabled public write access.

Re: Javascript - global, persistent array 2 years 11 months ago #64350

  • c_schmitz
  • c_schmitz's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 746
  • Thank you received: 101
  • Karma: 87
Google is your friend ;):

pablotron.org/?cid=1557
Support us, too. Donate to the LimeSurvey project and help keep us going!
The administrator has disabled public write access.
The following user(s) said Thank You: doodsonj

Re: Javascript - global, persistent array 2 years 11 months ago #64352

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4066
  • Thank you received: 745
  • Karma: 341
Nice find c_schmitz. Have you tested at all?
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.

Re: Javascript - global, persistent array 2 years 11 months ago #64353

  • doodsonj
  • doodsonj's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 30
  • Thank you received: 2
  • Karma: 2
Hi both,

I ended up creating quite an ugly solution.

Writing to a hidden field, then loading it on the next page using a INSERTANS, using a range of join, split and splice. It took me a while to do because I'm using multi-dimensional arrays (well, arrays within arrays within arrays) and so I had to join, split, splice recursively. My solution isn't hugely elegant, and c_schmitz found an great solution!

I had actually Google'd and am disappointed that the solution didn't pop up (I guess it was because I was typing in 'multidimensional' as well in my search term.

Thanks c_schmitz. Really useful to have this in my repository.

J.
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.118 seconds
Donation Image