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

TOPIC: Changing the value of a previous question

Changing the value of a previous question 4 years 3 days ago #89382

I have currently set up a variable called isvalid which I am setting to 1 by default. When I ask q1, if the respondent answers this with a value of 2 I want this to reset the value of isvalid to 2.

I have set up a separate equation question with the following text in the question field - yet it doesn;t seem to be doing this validation.
{if (q1=='2',isvalid=='2',isvalid=='1')}

JavaScript is enabled and I am using v1.92 build 120909.

I think this is a simple problem to fix but just can't seem to work this out.

Many thanks
The administrator has disabled public write access.

Changing the value of a previous question 4 years 3 days ago #89410

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 6566
  • Thank you received: 1477
  • Karma: 578
Is "isvalid" just a JavaScript variable or a question code?
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The administrator has disabled public write access.

Changing the value of a previous question 4 years 11 hours ago #89472

“isvalid” is a question. Thanks

Cheers,
Mark.
The administrator has disabled public write access.

Changing the value of a previous question 4 years 5 hours ago #89495

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 6566
  • Thank you received: 1477
  • Karma: 578
As far as I know, you cannot use an equation question to set the value of another question.

You may need to use JavaScript to do this. (with a listener on q1)
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The administrator has disabled public write access.

Changing the value of a previous question 4 years 4 hours ago #89507

  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • Moderator Lime
  • Posts: 9555
  • Thank you received: 1372
  • Karma: 389
Yep,

Or easy way:
QCODE: isvalid
QTEXT: {if (q1=='2','2','1')}
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time (Need support ?).
A bug not reported is a bug not corrected. | 2.61lts version improved | Need plugins for LimeSurvey ?
The administrator has disabled public write access.

Changing the value of a previous question 3 years 11 months ago #89608

Thanks for this - that works fine for one questions.

If I was needing to revalidate the contents of isvalid later on (for instance checking if q5 was 1), how would be the best way to do this?

thanks
Mark
The administrator has disabled public write access.

Changing the value of a previous question 3 years 11 months ago #89640

  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • Moderator Lime
  • Posts: 9555
  • Thank you received: 1372
  • Karma: 389
2 Equation question:

1st:
QCODE: isavlid1
QTEXT: {if (q1=='2','2','1')}

2nd (or at end)
QCODE: isavlid
QTEXT: {if (q5=='1' and isvalid1=='1','1',isvalid1)}

Think it worked.

Denis
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time (Need support ?).
A bug not reported is a bug not corrected. | 2.61lts version improved | Need plugins for LimeSurvey ?
The administrator has disabled public write access.
Time to create page: 0.386 seconds
Imprint                   Privacy policy         General Terms & Conditions         Revocation information and revocation form