Welcome to the LimeSurvey Community Forum

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

Autofilling Question Based on Previous Responses

  • ddanes
  • ddanes's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
2 years 5 months ago - 2 years 5 months ago #232027 by ddanes
Please help us help you and fill where relevant:
Your LimeSurvey version:  Version 5.4.0
Own server or LimeSurvey hosting: Own Server
Survey theme/template: Vanilla
==================
Hello!

I am looking to fill in a question based on another questions previous response.

For example, in my scenario, I want to fill question C with the answer 0 if questions A and B are 0. However, I want my question to still be asked if the condition (questions A and B == 0) is not met.

Also, I want the question C to be hidden if questions A and B are both 0, I have that working using conditional statements currently.

I got this working with an equation question as a separate question, but I am looking for a way to do this within the original question C without the need for a separate always hidden equation question.

The equation I have within that extra equation question is {if(A==0 && A1==0,0)}

Thank you!
 
Last edit: 2 years 5 months ago by ddanes. Reason: added that I want the question to be hidden

Please Log in to join the conversation.

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 years 5 months ago #232036 by tpartner
An idea...

1) Insert a hidden equation question after C to set the value of that question:
Code:
{C = if(A==0 && A1==0, 0, C)}

2) Place something like this in the CSS class field for question C:
Code:
{if(A==0 && A1==0, 'hidden', '')}

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

Please Log in to join the conversation.

  • ddanes
  • ddanes's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
2 years 5 months ago - 2 years 5 months ago #232037 by ddanes
Hello!

I just tried that, it seems that question C is hidden even if the answer to A or A1 isn't 0. I do not have always hidden on.

It also autofills answer C as 0 every single time, even if the answers to A and/or A1 are not 0.I'm not sure why this problem is happening.

Edit: I attached my survey that I am using to test   

Thank you!
Last edit: 2 years 5 months ago by ddanes. Reason: added survey

Please Log in to join the conversation.

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 years 5 months ago #232038 by tpartner
A couple of problems...

Regarding not being hidden, you will need to move C (actually, B in your survey) and the equation question to a different group.

Regarding auto-filling, you need to remove the unnecessary <pre> tags from the equation question and you need to remove the default answer of 0 from C (actually, B in your survey).

 

Sample survey attached:  

File Attachment:

File Name: limesurvey...3(1).lss
File Size:45 KB

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

Please Log in to join the conversation.

  • ddanes
  • ddanes's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
2 years 5 months ago #232039 by ddanes
Awesome! It works! Is there any way to remove the equation questions answer from the actual response now? For example, if the answer to B in my survey is 0, then the answer to C in my survey (equation question) is also read 0. Same for if B is 325, then C is read as 325 in the responses.

Is there any way I can completely remove the equation question from my response table?

Thank you!

Please Log in to join the conversation.

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 years 5 months ago #232040 by tpartner
No.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

Please Log in to join the conversation.

  • ddanes
  • ddanes's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
2 years 5 months ago #232041 by ddanes
Okay, Thank you so much for the help!

Please Log in to join the conversation.

Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose