Welcome, Guest
Username: Password: Remember me

TOPIC: Insert either the answer to a question, or the corresponding Other

Insert either the answer to a question, or the corresponding Other 3 years 3 months ago #64947

  • vadindot
  • vadindot's Avatar
  • OFFLINE
  • Senior Lime
  • Posts: 52
  • Thank you received: 1
  • Karma: 0
I have a question with 3 responses and Other.

In several of the follow up questions, I need to insert this answer. If they choose "Other" I need to display the appropriate text (but NOT the word Other which is what happens when I just put in both fields.
The administrator has disabled public write access.

Re: Insert either the answer to a question, or the corresponding Other 3 years 3 months ago #64949

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4371
  • Thank you received: 829
  • Karma: 381
You should be able to replace the value returned by {INSERTANS}. Have a look at this post for inspiration - www.limesurvey.org/en/forum/can-i-do-thi...ifferent-lines#61317

In your case the replace line would look something like:
prevAnswers = prevAnswers.replace(/Other/, 'Your new text');
Cheers,
Tony Partner

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

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.

Re: Insert either the answer to a question, or the corresponding Other 3 years 3 months ago #64951

  • vadindot
  • vadindot's Avatar
  • OFFLINE
  • Senior Lime
  • Posts: 52
  • Thank you received: 1
  • Karma: 0
so like this? (44 being the "Other" response)
prevAnswers = prevAnswers.replace(/Other/, {INSERTANS:11111X22X44});
The administrator has disabled public write access.

Re: Insert either the answer to a question, or the corresponding Other 3 years 3 months ago #64958

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4371
  • Thank you received: 829
  • Karma: 381
No. In my code, if "Other" is found in the span element, it will be replaced with "Your new text".

In other words, if {INSERTANS:11111X22X44} returns "Other", then "Your new text" will be inserted in it's place.
Cheers,
Tony Partner

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

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.200 seconds
Donation Image