Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1
  • 2

TOPIC: Unique Suffix by Row for an Array Question

Unique Suffix by Row for an Array Question 4 months 4 days ago #106814

  • rezyface
  • rezyface's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 6
  • Karma: 0
Hi all,

First of all big thank you (Vielen Dank!) to LimeSurvey Dev team!
My question I think is fairly straight forward. We have previously seen that LimeSurvey can be manipulated to add a unique suffix per column for an Array question.
See here:
www.limesurvey.org/en/forum/can-i-do-thi...-multi-flexible-text

However my Javascript knowledge is not sufficient to translate that to be row based instead of column.

For example I would like the array to look like:

Minimum for all Participants Minimum for WIA Participants
Rate of Rentention ___________ % _____________ %
Wages at placement ___________ $ _____________ $

and so on.

Any helpful hints?

Thank you!
The administrator has disabled public write access.

Unique Suffix by Row for an Array Question 4 months 4 days ago #106835

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4072
  • Thank you received: 748
  • Karma: 341
This should do the trick for row-specific suffixes.

<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
		addSuffixByRow({QID}, '%', '$', 'hours', 'km');
 
		// Function to add row-specific suffixes to an array
		function addSuffixByRow() {
 
			var qID = $(arguments)[0];
 
			// Some styling
			$('#question'+qID+' input[type="text"]').css({
				'width': '50%'
			});
 
			// Insert the suffixes
			$(arguments).each(function(i, val){
				if(i > 0) {
					$('#question'+qID+' tr.subquestion-list:eq('+(i-1)+') input[type="text"]').after(this);
				}
			});
		}
	});
</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.

Unique Suffix by Row for an Array Question 4 months 3 days ago #106855

  • rezyface
  • rezyface's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 6
  • Karma: 0
Thank you so much for the quick response! Unfortunately, while the input boxes are being resized appropriately the actual suffixes are not being added. I have inserted an "alert" statement into the if(i >0) statement in your code below and I do get 4 "alert" messages so we are iterating correctly. I am using an "Array Numbers" question type. I have added a screenshot for you to see the question.

Any ideas?

Thank you!

Q13d.jpg
The administrator has disabled public write access.

Unique Suffix by Row for an Array Question 4 months 3 days ago #106856

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4072
  • Thank you received: 748
  • Karma: 341
Please activate a sample survey so I can see the source code.
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.

Unique Suffix by Row for an Array Question 4 months 3 days ago #106859

  • rezyface
  • rezyface's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 6
  • Karma: 0
Hello,
Here is a test link with just the 1 question plus your code. As you will note, the text input boxes have widened appropriately but the suffixes have not been added.

Thank you!

survey.altarum.org/limesurvey/index.php?sid=11978&lang=en
The administrator has disabled public write access.

Unique Suffix by Row for an Array Question 4 months 3 days ago #106862

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4072
  • Thank you received: 748
  • Karma: 341
The code I supplied is for LimeSurvey version 2.05. You must be using an older version.

Replace this line:
$('#question'+qID+' tr.subquestion-list:eq('+(i-1)+') input[type="text"]').after(this);

With this:
$('#question'+qID+' tbody[id^="javatbd"]:eq('+(i-1)+') input[type="text"]').after(this);


.
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.

Unique Suffix by Row for an Array Question 4 months 3 days ago #106865

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4072
  • Thank you received: 748
  • Karma: 341
I can see that you are still having problems.

What LS version are you using and can you attach an export of that survey?


.
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.

Unique Suffix by Row for an Array Question 4 months 3 days ago #106866

  • rezyface
  • rezyface's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 6
  • Karma: 0
Hi,
Sorry the Lime version should have been the first thing mentioned. Using version 1.92+ Build 120909.

I replaced the line as you had said but still "no potatoes". The link above is still active and reflects the altered code.

So sorry for the hassle. Appreciate any guidance you may give.

Vielen Dank!
The administrator has disabled public write access.

Unique Suffix by Row for an Array Question 4 months 3 days ago #106869

  • rezyface
  • rezyface's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 6
  • Karma: 0
I have attached the test survey (found in the link above).

Thanks!
Attachments:
The administrator has disabled public write access.

Unique Suffix by Row for an Array Question 4 months 3 days ago #106870

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4072
  • Thank you received: 748
  • Karma: 341
Can you attach an export of that survey?
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.
  • Page:
  • 1
  • 2
Moderators: ITEd
Time to create page: 0.140 seconds
Donation Image