Welcome, Guest
Username: Password: Remember me

TOPIC: Save data from hidden question

Save data from hidden question 6 months 1 week ago #107243

  • LimeLight
  • LimeLight's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 2
  • 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 6 months 1 week ago #107248

  • holch
  • holch's Avatar
  • NOW ONLINE
  • LimeSurvey Team
  • Posts: 2823
  • Thank you received: 353
  • Karma: 121
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 | Question Attributes | Workarounds

If you found this answer helpful and it saved you some time please consider a donation to the project to keep Limesurvey going!
The administrator has disabled public write access.

Save data from hidden question 6 months 1 week ago #107266

  • boyan
  • boyan'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 6 months 1 week ago #107268

  • holch
  • holch's Avatar
  • NOW ONLINE
  • LimeSurvey Team
  • Posts: 2823
  • Thank you received: 353
  • Karma: 121
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 | Question Attributes | Workarounds

If you found this answer helpful and it saved you some time please consider a donation to the project to keep Limesurvey going!
The administrator has disabled public write access.

Save data from hidden question 6 months 1 week ago #107269

  • TMSWhite
  • TMSWhite's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 759
  • Thank you received: 82
  • Karma: 36
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 6 months 1 week ago #107278

  • DenisChenu
  • DenisChenu's Avatar
  • OFFLINE
  • Moderator Lime
  • Posts: 6429
  • Thank you received: 839
  • Karma: 249
Hi,

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

No ability to use javascript

;)
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.123 seconds
Donation Image