Welcome to the LimeSurvey Community Forum

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

Can I change question text based on passed parameter?

  • blocka
  • blocka's Avatar Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
7 years 4 months ago #144366 by blocka
We run a couple of workshops, and we'd like to collect survey data what people think of the workshop.
We have a few questions that have the same text, irrespective of the workshop, and a number of questions where we'd like to include the name of the workshop, along with maybe a few other textual changes.

My thinking is to pass the name of the workshop in the survey URL, and have the value saved to a hidden field (so later we can filter responses by workshop). I'm hazarding a guess that using Javascript, I could modify the text of relevant questions by checking the value of the value in the hidden field, so I could replace a few inline tokens with the text I need for each question.

So I could have a question like:
Would you recommend {workshopname} to your {target}?

and if the hidden field value was Falcon Training, I could display the question as:
Would you recommend Falcon Training to your friends?

or if the hidden field value was Help the Elderly, I could display the question as:
Would you recommend Help the Elderly to your children?

Can anyone confirm if this is possible, and perhaps give an example of how to write the Javascript?
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 4 months ago - 7 years 4 months ago #144369 by Joffm
Hi, blocka,
you do not need javascript.
Everything is there.

1. Your workshopname.
The name is passed in the url, e.g. www.limesurvey.com/lime/...../lang=en ?wn=Workshop1
In the first hidden question (wn) (e.g. short text) you insert in the questiontext {wn}, to grab the workshopname.

2. Your target
If the target depends on an answer of a question Q2 like
1=friends
2=children
3=colleagues

you enter in the question text
Would you recommend {wn} to your {Q2.shown}?
or
Would you recommend {wn} to your {if(Q2==1,"friends",if(Q2==2,"children","colleagues"))}?

Depends on the way you calculate the target.

sample attached

Best regards
Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 7 years 4 months ago by Joffm. Reason: Typo
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose