Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

How to retain a var value from page to page without re-initializing

  • cheeseburger
  • cheeseburger's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
2 years 9 months ago #217008 by cheeseburger
Hi, As a test, I had placed some basic javascript at various points in the code (that is a LS survey) to see if any areas are not replaced when a user clicks "next" in a paginated survey. Although it appeared to use AJAX or PJAX, and I do see a div that appears to be named as the element in which content is replaced, all of my test variables are still re-initialized as if the entire page has reloaded.

For smaller needs, I usually place values inside of a question and retain them as needed. However, for larger needs such as complex multidimensional arrays or JS objects, I still need to retain them in a more traditional coded way, and that could be in a session variable. I spent a few hours researching to see if there is a way in which I could utilize something at the TWIG level, but although I found a bunch of suggestions online and in the docs, nothing seems to be working.

Do you know of any methods to initialize a variable, update it, and set/get across a multi page survey without having to use a question in the survey to place your values? Via Javascript/JQuery? or TWIG Session Variables? Or if needed, I will just use PHP Session Variables. 

Currently using Version 3.27.2 LimeSurvey
Thanks!
 
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 years 9 months ago #217012 by tpartner

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • cheeseburger
  • cheeseburger's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
2 years 9 months ago #217427 by cheeseburger
Thank you Tony. I finally came back around to work on this and local storage is working really well. Thanks again!
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose