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

TOPIC: Javascript - global, persistent array

Javascript - global, persistent array 4 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.

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

  • c_schmitz
  • c_schmitz's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 999
  • 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

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

  • tpartner
  • tpartner's Avatar
  • Online
  • LimeSurvey Team
  • Posts: 6139
  • Thank you received: 1363
  • Karma: 535
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 4 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.750 seconds
Imprint                   Data Protection Statement                  Revocation information and revocation form