Check out the LimeSurvey source code on GitHub!
Welcome, Guest
Username: Password:

TOPIC: Javascript - global, persistent array

Javascript - global, persistent array 5 years 4 months ago #64347

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.

Javascript - global, persistent array 5 years 4 months ago #64350

  • c_schmitz
  • c_schmitz's Avatar
  • Online
  • LimeSurvey Team
  • Posts: 1033
  • Thank you received: 135
  • Karma: 97
Google is your friend ;):

pablotron.org/?cid=1557
Best regards

Carsten Schmitz
LimeSurvey project leader
The administrator has disabled public write access.
The following user(s) said Thank You: doodsonj_duplicate

Javascript - global, persistent array 5 years 4 months ago #64352

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 6570
  • Thank you received: 1477
  • Karma: 579
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.
The administrator has disabled public write access.

Javascript - global, persistent array 5 years 4 months ago #64353

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.
Time to create page: 0.838 seconds
Imprint                   Privacy policy         General Terms & Conditions         Revocation information and revocation form