Accessing SessionStorage or localStorage

More
6 years 2 months ago #133559 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.
More
6 years 2 months ago #133569 by tpartner
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.
More
6 years 2 months ago #133577 by jmdsbussrv
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.
More
6 years 2 months ago #133696 by DenisChenu
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.
More
6 years 2 months ago #133967 by jmdsbussrv
Thanks, Denis, I'll give it a shot and see what happens.
The topic has been locked.
More
6 years 2 months ago #134300 by jmdsbussrv
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.
More
6 years 2 months ago #134409 by Mazi
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
Contact: marcel.minke(at)survey-consulting.com
Want to use your survey offline -> www.offlinesurveys.com
The topic has been locked.
More
6 years 2 months ago #134451 by DenisChenu
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.

Start now!

Just create your account and start using Limesurvey today.

Register now