Welcome to the LimeSurvey Community Forum

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

Update values of question in multipage survey BEFORE clicking next?

  • cheeseburger
  • cheeseburger's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
3 years 3 weeks ago #214112 by cheeseburger
Hi everyone. I have a simple test survey with four questions. Let's call them A,B,C,D.   A and B are short text fields with numeric values. C is a short text field that will populate with the value of A minus B. I am performing the math in D which is an equation field. I am also assigning the value to C (from the equation field) after the math is performed.     The equation field is located AFTER the other questions as I expect order of execution may be related to position. The survey is a multi group survey displayed as three pages (screens). The questions in the other groups are just placeholders so that I can test the ABCD screen to see how things act within a paginated scenario. 

What works:
When I get to the screen with ABCD, I see the math has properly worked and the assignment of values have all worked (I use default answers for the questions and the math happens as soon as I navigate to the screen). 

The challenge:
If I update the value or A or B, the math doesn't recompute unless I click the NEXT button. Is there a TRIGGER of some sort that I need to implement in order for the math to update as the fields are updated? 

The goal:
Upon A or B being updated with its values, I want C to reflect the change in values as it recomputes A minus B. And I'm trying to achieve this goal without clicking the NEXT button. For example, on blur from any of the A or B fields. 

Thanks!
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 3 weeks ago #214143 by tpartner
The ExpressionScript assignment operator is only fired on page load or submit. If you want real-time updating, you will need to use JavaScript.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: DenisChenu
The topic has been locked.
  • cheeseburger
  • cheeseburger's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
3 years 2 weeks ago #214443 by cheeseburger
Thank you Tony! Your guidance was helpful and shifting over to using JS to achieve the goal worked perfectly. The trick for me, as learned in your other posts, was to assign a value to a question and then trigger('keyup') for it to finalize the process. I attached all of my actions to a BLUR event for the related input fields (this info is for future users searching for similar questions). Thanks!
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose