Willkommen, Gast
Benutzername: Passwort: Angemeldet bleiben:

THEMA: Suffix in an Array (Multi Flexible) (Text)

Suffix in an Array (Multi Flexible) (Text) 2 Jahre 1 Monat her #83066

  • FLF
  • FLFs Avatar
  • OFFLINE
  • Junior Lime
  • Beiträge: 24
  • Karma: 0
Hi,
I am looking for a solution, I think it's necessary to use javascript, but unfortunately I can't write javascript :blush: :( .
Well, I need a text-array-question with suffix like in the fake-image at the bottom.
In one column I ask for gains in € and in the next column I asked for percentage.
All in all the question is very complex and the suffixs would be a great help for the participants.
Beside this, I have a similar problem with a multiple options question with comments, it would be great to have suffix also there.

I would be very grateful, if you could help me.

[attachment:1]matrix.jpg[/attachment]
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: Suffix in an Array (Multi Flexible) (Text) 2 Jahre 1 Monat her #83074

  • tpartner
  • tpartners Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 4117
  • Dank erhalten: 760
  • Karma: 346
No image attached.
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.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Aw: Suffix in an Array (Multi Flexible) (Text) 2 Jahre 1 Monat her #83095

  • FLF
  • FLFs Avatar
  • OFFLINE
  • Junior Lime
  • Beiträge: 24
  • Karma: 0
sorry, here it is

matrix_2012-07-06.jpg
Letzte Änderung: 2 Jahre 1 Monat her von FLF.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: Suffix in an Array (Multi Flexible) (Text) 2 Jahre 1 Monat her #83121

  • tpartner
  • tpartners Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 4117
  • Dank erhalten: 760
  • Karma: 346
1) Set up your survey to use JavaScript.

2) Add the following script to the source of the array. Replace "12345" with the array question ID and modify the suffixes as required.

The function call must consist of a question ID followed by the suffixes yo want in each column. Suffixes must be enclosed in quotes and comma separated.

So, in the example, question ID 12345 will get an "in €" suffix in the first column and an "in %" in the next 3 columns.
<script type="text/javascript" charset="utf-8">
 
	$(document).ready(function() {
 
		// Call the function with the question ID followed by a comma-separated list of suffixes
		addSuffix(12345, 'in €', 'in %', 'in %', 'in %');
 
		function addSuffix() {
 
			var qID = $(arguments)[0];
 
			// Assign some column-specific classes
			$('#question'+qID+' table.question tbody tr').each(function(i){
				$('td', this).each(function(i){
					$(this).addClass('answerCol-'+(i+1)+'');
				});
			});
 
			// Some styling
			$('#question'+qID+' table.question tbody input[type="text"]').css({
				'width': '50%'
			});
 
			// Insert the suffixes
			$(arguments).each(function(i, val){
				if(i > 0) {
					$('#question'+qID+' td.answerCol-'+i+' label').append(val);
				}
			});
		}
	});
 
</script>


Capture2_2012-07-06.JPG
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.
Letzte Änderung: 2 Jahre 1 Monat her von tpartner.
Der Administrator hat öffentliche Schreibrechte deaktiviert.
Folgende Benutzer bedankten sich: mozart

Aw: Suffix in an Array (Multi Flexible) (Text) 2 Jahre 1 Monat her #83123

  • FLF
  • FLFs Avatar
  • OFFLINE
  • Junior Lime
  • Beiträge: 24
  • Karma: 0
amazing!!!
Thank you so much!!!
:laugh: :cheer: :silly: :cheer: :laugh:
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Aw: Re: Suffix in an Array (Multi Flexible) (Text) 2 Jahre 1 Monat her #83125

  • holch
  • holchs Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 2605
  • Dank erhalten: 302
  • Karma: 110
Very nice, Tpartner!

I would volunteer to put this into the work around section.

Just one quick question, because it might be only a small difference: is it possible to do prefixes with this as well?
Have a look at the manual! It is a really valuable source for information. Here some helpful links:
Manual (EN) | Question Types | Question Attributes | Workarounds

If you found this answer helpful and it saved you some time please consider a donation to the project to keep Limesurvey going!
Letzte Änderung: 2 Jahre 1 Monat her von holch.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: Aw: Re: Suffix in an Array (Multi Flexible) (Text) 2 Jahre 1 Monat her #83126

  • tpartner
  • tpartners Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 4117
  • Dank erhalten: 760
  • Karma: 346
Just one quick question, because it might be only a small difference: is it possible to do prefixes with this as well?

You should be able to do so by changing this:
$('#question'+qID+' td.answerCol-'+i+' label').append(val);

To this:
$('#question'+qID+' td.answerCol-'+i+' label').prepend(val);
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.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: Aw: Re: Suffix in an Array (Multi Flexible) (Text) 2 Jahre 1 Monat her #83141

  • holch
  • holchs Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 2605
  • Dank erhalten: 302
  • Karma: 110
Works like a charm and is added to the workaround section:
docs.limesurvey.org/Workarounds%3A+Manip...ot_Array_Texts_quot_
Have a look at the manual! It is a really valuable source for information. Here some helpful links:
Manual (EN) | Question Types | Question Attributes | Workarounds

If you found this answer helpful and it saved you some time please consider a donation to the project to keep Limesurvey going!
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: Suffix in an Array (Multi Flexible) (Text) 1 Jahr 6 Monate her #92247

  • mozart
  • mozarts Avatar
  • OFFLINE
  • Fresh Lemon
  • Beiträge: 4
  • Karma: 0
Hey, nice Code, thank you for this.

I am in a need for a bit different solution and wanted you to ask if this is possible.

Is it possible to use a suffix in only one column ?
Or, the other way around, is it possible to hide suffixes of specific columns?
(I have build an optional list, and i just need one suffix for the "others" input mask.)

If you have an idea i would love to hear it.

Best regards,
mozart
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: Suffix in an Array (Multi Flexible) (Text) 1 Jahr 6 Monate her #92278

  • tpartner
  • tpartners Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 4117
  • Dank erhalten: 760
  • Karma: 346
If you only want the suffix in the last column, do something like this:
		// Call the function with the question ID followed by a comma-separated list of suffixes
		addSuffix(12345, '', '', '', 'Other Suffix');
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.
Der Administrator hat öffentliche Schreibrechte deaktiviert.
Moderatoren: ITEd
Ladezeit der Seite: 0.179 Sekunden
Donation Image