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

TOPIC: Save data from hidden question

Save data from hidden question 2 years 7 months ago #107243

  • LimeLight
  • LimeLight's Avatar
  • Offline
  • Fresh Lemon
  • Posts: 6
  • Karma: 0
Hi,

I'm generating a GUID via a javascript. I'm printing it to a long textfield. However, when i set the question to "always hide this question" the GUID is not stored among the answers. How can I make the GUID stick to the answer table while still being hidden?

// TIA
The administrator has disabled public write access.

Save data from hidden question 2 years 7 months ago #107248

  • holch
  • holch's Avatar
  • Online
  • LimeSurvey Team
  • Posts: 5428
  • Thank you received: 809
  • Karma: 240
You can't write to a question which is hidden via "always hide this question" because it does no show up in the HTML code and you can only write with Javascript to a question that is in the HTML code.

What you need to do is hide the question via CSS, thus it is just not shown in the browser, but it is still in the html code and thus read and writable via JS.
Have a look at the manual! It is a really valuable source for information. Here some helpful links:
Manual (EN) | Question Types | [url=https://manual.limesurvey.org/Workarounds[/url]

If you found this answer helpful and it saved you some time please consider a [url=https://donate.limesurvey.org[/url] to the...
The administrator has disabled public write access.

Save data from hidden question 2 years 7 months ago #107266

  • byan
  • byan's Avatar
  • Offline
  • Senior Lime
  • Posts: 49
  • Thank you received: 9
  • Karma: 1
Alternatively, you can write $("#questionID").hide(); in the question box or help box if you don't want to mess with CSS.
The administrator has disabled public write access.
The following user(s) said Thank You: holch

Save data from hidden question 2 years 7 months ago #107268

  • holch
  • holch's Avatar
  • Online
  • LimeSurvey Team
  • Posts: 5428
  • Thank you received: 809
  • Karma: 240
I didn't know this one. That is an interesting alternative, because you don't need to make chances to the template css.
Have a look at the manual! It is a really valuable source for information. Here some helpful links:
Manual (EN) | Question Types | [url=https://manual.limesurvey.org/Workarounds[/url]

If you found this answer helpful and it saved you some time please consider a [url=https://donate.limesurvey.org[/url] to the...
The administrator has disabled public write access.

Save data from hidden question 2 years 7 months ago #107269

  • TMSWhite
  • TMSWhite's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 758
  • Thank you received: 84
  • Karma: 37
If the goal is to have the GUID stored in the database, then you can use an Equation question to do this. Equations are unique among questions types in that their value is always saved to the database even if the always_hidden attribute is set. For all other question types, if the question is hidden by always_hidden, or relevance (e.g. the question is not applicable), then the database stores NULL for that question.
The administrator has disabled public write access.

Save data from hidden question 2 years 7 months ago #107278

  • DenisChenu
  • DenisChenu's Avatar
  • Online
  • Moderator Lime
  • Posts: 9580
  • Thank you received: 1374
  • Karma: 390
Hi,

@Thomas : hidden => save in DB : default value OR value set by Equation ( Q1="Answer ).

No ability to use javascript

;)
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (use private message).
The administrator has disabled public write access.
Time to create page: 0.397 seconds
Imprint                   Privacy policy         General Terms & Conditions         Revocation information and revocation form