Welcome to the LimeSurvey Community Forum

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

Accessing SessionStorage or localStorage

  • jmdsbussrv
  • jmdsbussrv's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
7 years 11 months ago #133559 by jmdsbussrv
Accessing SessionStorage or localStorage was created by jmdsbussrv
OK, been on this for the whole day.

I am trying to import the data stored in sessionStorage (and have tried localStorage) into an equation question.
The syntax (below) works on my other webpage, but doesn't seem to work in the equation. It generates a "null" result.

Here is the syntax in the equation:
<script>
document.write(sessionStorage.getItem("repnamelp2"));
</script>

NOTE - if I use this javascript, it gives the correct "TESTING" result:
<script>
sessionStorage.setItem("repnametest", "TESTING");
document.write(sessionStorage.getItem("repnametest"));
</script>
but the first one is the one I want working.

Any thoughts on why it cannot capture the data?

Thanks.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 11 months ago #133569 by tpartner
Replied by tpartner on topic Accessing SessionStorage or localStorage
You are referring to browser local storage and, as far as I know, LimeSurvey doesn't use that.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • jmdsbussrv
  • jmdsbussrv's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
7 years 11 months ago #133577 by jmdsbussrv
Replied by jmdsbussrv on topic Accessing SessionStorage or localStorage
You always come through for people here Tony. Thanks.

The second instance shows that LS can access the storage successfully, but I wonder if it has something to do with LS clearing the storage upon loading, but that's way beyond our pay grades. :)

I will start another topic on a work-around thought I had.

Thanks.
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 11 months ago #133696 by DenisChenu
Replied by DenisChenu on topic Accessing SessionStorage or localStorage
Hi,

For javascript : always use jquery , replace document.write by $("#anelement").html(sessionStorage.getItem("repnametest")); for example.

Denis

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.
  • jmdsbussrv
  • jmdsbussrv's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
7 years 11 months ago #133967 by jmdsbussrv
Replied by jmdsbussrv on topic Accessing SessionStorage or localStorage
Thanks, Denis, I'll give it a shot and see what happens.
The topic has been locked.
  • jmdsbussrv
  • jmdsbussrv's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
7 years 11 months ago #134300 by jmdsbussrv
Replied by jmdsbussrv on topic Accessing SessionStorage or localStorage
Hi, Denis, I tried using the code you supplied, but it wasn't working, possibly likely because I don't have the syntax correct.

I have been able to use session.Storage AFTER LimeSurvey loads and been able to "setItem" in one survey and then immediately transfer to the next survey (totally different one) and then use "getItem" to retrieve the information, and it works perfectly. Issue is that I cannot seem to get the information to be used elsewhere in LimeSurvey. Here is the detailed information on my other post:

www.limesurvey.org/forum/can-i-do-this-w...ey-to-another#134299

If you have any insight into this, I would sincerely appreciate it.

Thanks.
The topic has been locked.
  • Mazi
  • Mazi's Avatar
  • Offline
  • Official LimeSurvey Partner
  • Official LimeSurvey Partner
More
7 years 11 months ago #134409 by Mazi
Replied by Mazi on topic Accessing SessionStorage or localStorage
Can you provide some background information about what you need/want to use this for?

Best regards/Beste Grüße,
Dr. Marcel Minke
Need Help? We offer professional Limesurvey support: survey-consulting.com
Contact: marcel.minke(at)survey-consulting.com
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 11 months ago #134451 by DenisChenu
Replied by DenisChenu on topic Accessing SessionStorage or localStorage
With $("#anelement") : you need an element with id='anelement' .

Maybe best is to upload a litlle survey with 2 group.

ANd something other : don't use equation question : because equation is done in PHP.

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose