Welcome, Guest
Username: Password: Remember me

TOPIC: Change Question Group description based on token

Change Question Group description based on token 3 years 6 months ago #61735

  • waitz
  • waitz's Avatar
  • OFFLINE
  • Gold Lime
  • Posts: 171
  • Thank you received: 1
  • Karma: 3
Is there a way I can hack my way into changing a question group description based on a value in one of my tokens?
Version 1.91+ Build 11232 | PHP 5.3.9 | MySQL 5.1.56 |
The administrator has disabled public write access.

Re: Change Question Group description based on token 3 years 6 months ago #61779

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4410
  • Thank you received: 842
  • Karma: 385
You can use JavaScript to dynamically change the description. The details would vary by template but this should work for the default template.

1) Set up your survey to use JavaScript.

2) Add the following script to the source of the group description.
<script type="text/javascript" charset="utf-8">
 
	$(document).ready(function() {
 
		if('{TOKEN:ATTRIBUTE_1}' == 'x') {
			$('span.group-description').text('Some new group description.');
		}
 
	});
 
</script>
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: Change Question Group description based on token 3 years 6 months ago #61785

  • waitz
  • waitz's Avatar
  • OFFLINE
  • Gold Lime
  • Posts: 171
  • Thank you received: 1
  • Karma: 3
Great, interesting. I have already set it up for javascript, so I'll try adding the code.

Could I use the same idea for showing / hiding some of the sub questions in a 'Multiple options with comments': www.limesurvey.org/en/forum/can-i-do-thi...ition-on-subquestion ?
Version 1.91+ Build 11232 | PHP 5.3.9 | MySQL 5.1.56 |
The administrator has disabled public write access.

Re: Change Question Group description based on token 3 years 6 months ago #61787

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4410
  • Thank you received: 842
  • Karma: 385
I just posted a solution there.
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: Change Question Group description based on token 3 years 6 months ago #62171

  • waitz
  • waitz's Avatar
  • OFFLINE
  • Gold Lime
  • Posts: 171
  • Thank you received: 1
  • Karma: 3
Hmmm, I actually don't get this one to work.

I changed the information above to:

'{TOKEN:ATTRIBUTE_30}' == '1'

So that if token 30 has value 1, show the following text. But it will not show....
Any reason?
Version 1.91+ Build 11232 | PHP 5.3.9 | MySQL 5.1.56 |
Last Edit: 3 years 6 months ago by waitz.
The administrator has disabled public write access.

Re: Change Question Group description based on token 3 years 6 months ago #62173

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4410
  • Thank you received: 842
  • Karma: 385
Are you using the default template?
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: Change Question Group description based on token 3 years 6 months ago #62174

  • waitz
  • waitz's Avatar
  • OFFLINE
  • Gold Lime
  • Posts: 171
  • Thank you received: 1
  • Karma: 3
I used limespired, otherwise everything else is default.
Version 1.91+ Build 11232 | PHP 5.3.9 | MySQL 5.1.56 |
The administrator has disabled public write access.

Re: Change Question Group description based on token 3 years 6 months ago #62175

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4410
  • Thank you received: 842
  • Karma: 385
Try this:
<script type="text/javascript" charset="utf-8">
 
	$(document).ready(function() {
 
		if('{TOKEN:ATTRIBUTE_30}' == '1') {
			$('.survey-groupdescription').text('Some new group description.');
		}
 
	});
 
</script>
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.

[SOLVED] Re: Change Question Group description based on token 3 years 6 months ago #62178

  • waitz
  • waitz's Avatar
  • OFFLINE
  • Gold Lime
  • Posts: 171
  • Thank you received: 1
  • Karma: 3
Yepp, that was it. Thanks again!
Version 1.91+ Build 11232 | PHP 5.3.9 | MySQL 5.1.56 |
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.151 seconds
Donation Image