Unique Suffix by Row for an Array Question

Mehr
3 Jahre 7 Monate her #106814 von rezyface
rezyface erstellte das Thema Unique Suffix by Row for an Array Question
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!

Bitte Anmelden um an der Konversation teilzunehmen.

Mehr
3 Jahre 7 Monate her #106835 von tpartner
tpartner antwortete auf das Thema: Unique Suffix by Row for an Array Question
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.

Bitte Anmelden um an der Konversation teilzunehmen.

Mehr
3 Jahre 7 Monate her #106855 von rezyface
rezyface antwortete auf das Thema: Unique Suffix by Row for an Array Question
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!

Anhang:

Bitte Anmelden um an der Konversation teilzunehmen.

Mehr
3 Jahre 7 Monate her #106856 von tpartner
tpartner antwortete auf das Thema: Unique Suffix by Row for an Array Question
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.

Bitte Anmelden um an der Konversation teilzunehmen.

Mehr
3 Jahre 7 Monate her #106859 von rezyface
rezyface antwortete auf das Thema: Unique Suffix by Row for an Array Question
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

Bitte Anmelden um an der Konversation teilzunehmen.

Mehr
3 Jahre 7 Monate her #106862 von tpartner
tpartner antwortete auf das Thema: Unique Suffix by Row for an Array Question
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.

Bitte Anmelden um an der Konversation teilzunehmen.

Mehr
3 Jahre 7 Monate her #106865 von tpartner
tpartner antwortete auf das Thema: Unique Suffix by Row for an Array Question
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.

Bitte Anmelden um an der Konversation teilzunehmen.

Mehr
3 Jahre 7 Monate her #106866 von rezyface
rezyface antwortete auf das Thema: Unique Suffix by Row for an Array Question
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!

Bitte Anmelden um an der Konversation teilzunehmen.

Mehr
3 Jahre 7 Monate her #106869 von rezyface
rezyface antwortete auf das Thema: Unique Suffix by Row for an Array Question
I have attached the test survey (found in the link above).

Thanks!
Anhang:

Bitte Anmelden um an der Konversation teilzunehmen.

Mehr
3 Jahre 7 Monate her #106870 von tpartner
tpartner antwortete auf das Thema: Unique Suffix by Row for an Array Question
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.

Bitte Anmelden um an der Konversation teilzunehmen.

Mehr
3 Jahre 7 Monate her #106875 von tpartner
tpartner antwortete auf das Thema: Unique Suffix by Row for an Array Question
Oops, for 1.92, that line should have bees this:
$('#question'+qID+' tbody[id^="javatbd"]:eq('+(i-1)+') input[type="text"]').after(val);

And you had one small syntax error - this {37581}, should be this {QID}.

Here is a working version:

Dateianhang:

Dateiname: limesurvey...1978.lss
Dateigröße:25 KB

Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Anhang:

Bitte Anmelden um an der Konversation teilzunehmen.

Mehr
3 Jahre 7 Monate her #106881 von rezyface
rezyface antwortete auf das Thema: Unique Suffix by Row for an Array Question
Thank you so much! Working like a charm now!

Do you have any specific website / book in mind that you would recommend for learning Javascript? Any website/book that would focus on Javascript as it applies to LimeSurvey?

My background: I use SAS professionally (been writing SAS programs that interact with the LimeSurvey SQL tables - quite fun) and I know a little Java as well as a much smaller amount of Perl. My HTML / JS knowledge is unfortunately minimal and any JS I have used in previous Lime surveys has been done by scouring the forums / manual and editing/testing copied code to make it work for my purposes.

Again, big thank you for your time!

Bitte Anmelden um an der Konversation teilzunehmen.

Mehr
3 Jahre 7 Monate her #106883 von DenisChenu
DenisChenu antwortete auf das Thema: Unique Suffix by Row for an Array Question

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).
An error happen ? Before make a new topic : remind the Debug mode .

Bitte Anmelden um an der Konversation teilzunehmen.

Jetzt loslegen!

Melden Sie sich jetzt an, und erstellen Sie in wenigen Minuten Ihre erste Umfrage.

Account einrichten

Abonnieren Sie unseren Newsletter

Abonnieren Sie unseren Newsletter für alle Neuigkeiten rund um LimeSurvey
captcha