Insert other specify text into subquestion text of later question

More
3 years 10 months ago #112262 by tixeon
tixeon created the topic: Insert other specify text into subquestion text of later question
I am sure this is really simple, but I am having trouble finding the instructions.

Here is what I am trying to do:

Q1 blah blah blah?
[multiple response]
>option 1
>option 2
>option 3
>other specify ____________

Q2 blah blah blah?
[array question set to only feed through those selected in Q1]
>option 1
>option 2
>option 3
>other - <insert text from freeform box in Q1>

So how do I insert the text in Q2?

Please Log in or Create an account to join the conversation.

More
3 years 10 months ago #112278 by tpartner
tpartner replied the topic: Insert other specify text into subquestion text of later question
Assuming your question codes are "Q1" and "Q2"...

In Q2, add a sub-question with code "othercbox". The text for this sub-question is:
Other: {Q1_other}

Here's a working survey.

File Attachment:

File Name: limesurvey...9-09.lss
File Size:25 KB




.

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

Please Log in or Create an account to join the conversation.

More
3 years 10 months ago #112313 by tixeon
tixeon replied the topic: Insert other specify text into subquestion text of later question
Thank you! Is there a way to make the Other in Q2 only appear if it is selected in Q1?
This method it appears as a row option in Q2 even if it isn't selected in Q1.

Please Log in or Create an account to join the conversation.

More
3 years 10 months ago #112338 by tpartner
tpartner replied the topic: Insert other specify text into subquestion text of later question
Ah, in 2.05 you cannot use "other" as a sub-question code so we'll have to work around it with a hidden option in Q1 and a little JavaScript.

1) Add a new sub-question to Q1 with code "myOther" (we'll hide this with JS).

2) Change the code of the "Other" sub-question in Q2 to "myOther". Its display is now filtered by our new option in Q1.

3) Add the following script to the source of Q1. It will hide the new option and togggle it depending on the state of the "Other" checkbox.
<script type="text/javascript" charset="utf-8">	
    $(document).ready(function(){
 
		// Identify this question
		var thisQuestion = $('#question{QID}');
		var thisOther = $('input.checkbox[id$="othercbox"]', thisQuestion);
		var thisOtherText = $('input.text[id$="other"]', thisQuestion);
		var otherToggle = $('input.checkbox[id$="myOther"]', thisQuestion);
 
		// Hide the "toggle" option
		$(otherToggle).closest('li.question-item ').hide();
 
		// Listeners on the inputs
		$(thisOther).change(function(e) {
			handleOther();
		});
		$(thisOtherText).on('change keyup', function(e) {
			handleOther();
		});
 
		// A function to check the "toggle" option depending on the state od "Other"
		function handleOther() {
			$(otherToggle).prop('checked', $(thisOther).prop('checked'));
			checkconditions($(otherToggle).attr('value'), $(otherToggle).attr('name'), $(otherToggle).attr('type'))
		}
	});
</script>

Here's the survey again with these changes.

Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Attachments:
The following user(s) said Thank You: tixeon

Please Log in or Create an account to join the conversation.

More
3 years 10 months ago #112368 by tixeon
tixeon replied the topic: Insert other specify text into subquestion text of later question
That worked perfectly, thank you so much!!

Please Log in or Create an account to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!