Seamlessy combine different multiple choice questions

More
4 years 3 weeks ago #95498 by Limer2001
Limer2001 created the topic: Seamlessy combine different multiple choice questions
I have a multiple choice question but the display of certain answers depends on token attributes. I don't think it's possible to hide certain answeringoptions based on tokens. So I rather make a multiple choice question with only one answering option. Hide the question text and minimize the bordering so in the end it looks like one multiple choice question.


So i added the following code. But it doesn't work.. And I also don't know how to delete the borders and make the different the multiple choice questions look like one question. Any thoughts on this?
<script type="text/javascript" charset="utf-8">
	$(document).ready(function() {
 
		var qID = {QID};
 
                $('#question'+qID+' .questiontext {display:none;}
 
}
</script>

Please Log in to join the conversation.

More
4 years 3 weeks ago #95500 by KRav
KRav replied the topic: Seamlessy combine different multiple choice questions
Hi,
the first step to make this working is the right syntax :-)

-> $('#question'+qID+' .questiontext').hide();

I'm not sure if the selector is the right one (depends on your theme). You should use the right chained selector.
Further more, if you want to make a decision on a token you must have an "if" in your script.

To manipulate the borders, you have to use the css() command.

Cheers Kai


research on BLOGS - Professional LimeSurvey support
Consultant - Templates - Training - JQuery magic - Support - Coding - Survey creation and more..

Contact
Professional LimeSurvey support
This email address is being protected from spambots. You need JavaScript enabled to view it.

Please Log in to join the conversation.

More
4 years 3 weeks ago #95502 by Limer2001
Limer2001 replied the topic: Seamlessy combine different multiple choice questions
Thanks for your quick response!

I can find this in my customtemplate :

.questiontext {
font-family: arial, verdana, sans-serif;
font-size: 12px;
font-weight: bold;
}

But the code you suggested doesn't work.


Greets,

Michel

Please Log in to join the conversation.

More
4 years 3 weeks ago #95523 by KRav
KRav replied the topic: Seamlessy combine different multiple choice questions
Hi michel,

as I said, the selector depends on your theme. Watch out for JS errors and chain step by step (maybe from child to parent) the selectors to have success.

Cheers Kai


research on BLOGS - Professional LimeSurvey support
Consultant - Templates - Training - JQuery magic - Support - Coding - Survey creation and more..

Contact
Professional LimeSurvey support
This email address is being protected from spambots. You need JavaScript enabled to view it.

Please Log in to join the conversation.

More
4 years 3 weeks ago #95533 by Limer2001
Limer2001 replied the topic: Seamlessy combine different multiple choice questions
I have to figure out what chain selection is first I think.

On another note, to get rid of the padding of the answer table I tried adding:

<script type="text/javascript" charset="utf-8"><br />
$(document).ready(function() {
$("answer").css("padding":"0em");
}
</script>



But it didnt work. Any suggestions? td class="answer"

Please Log in to join the conversation.

More
4 years 3 weeks ago #95545 by tpartner
tpartner replied the topic: Seamlessy combine different multiple choice questions
You forgot a dot in front of "answer":
$(".answer").css("padding":"0");

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

Please Log in to join the conversation.

More
4 years 3 weeks ago #95548 by Limer2001
Limer2001 replied the topic: Seamlessy combine different multiple choice questions
Hm still not working. :pinch:

Please Log in to join the conversation.

More
4 years 3 weeks ago #95549 by tpartner
tpartner replied the topic: Seamlessy combine different multiple choice questions
Unfortunately it's difficult to debug without knowing your template structure. Can you activate a sample survey wit those questions for us to see?

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

Please Log in to join the conversation.

More
4 years 3 weeks ago #95553 by Limer2001
Limer2001 replied the topic: Seamlessy combine different multiple choice questions
Here you go:
http://ima.nl/onderzoek1/index.php/594693/lang-nl

Thanks for your help so far!

Please Log in to join the conversation.

More
4 years 3 weeks ago #95559 by tpartner
tpartner replied the topic: Seamlessy combine different multiple choice questions

Hm still not working.

You have a <br /> tag inside your script which is breaking it.

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

Please Log in to join the conversation.

More
4 years 3 weeks ago #95565 by Limer2001
Limer2001 replied the topic: Seamlessy combine different multiple choice questions
Hm sloppy, removed it but still not working.

Please Log in to join the conversation.

More
4 years 3 weeks ago #95615 by tpartner
tpartner replied the topic: Seamlessy combine different multiple choice questions
You have a syntax error.

This line:
$(".answer").css("padding":"0");

Should be:
$(".answer").css("padding", "0");

Or:
$(".answer").css({
	"padding":"0"
});

The CSS required to make those two questions appear as one is:
#question436 table td {
  height: auto;
}
 
#question436 table.scs {
  border-bottom: 0 none;
}
 
#question436 .survey-question-help {
  display: none;
}
 
#question436 .subquestions-list {
  margin: 0;
}
 
#question436 .answer {
  padding: 0;
}
 
#question437 table.scs {
  border-top: 0 none;
}
 
#question437 td.be {
 display: none;
}
 
#question437 .survey-question-help {
  display: none;
}
 
#question437 .subquestions-list {
  margin: 0;
}
 
#question437 .answer {
  padding: 0;
}

So, to translate that into JavaScript, add this to the first question:
<script type="text/javascript" charset="utf-8">
	$(document).ready(function() {
 
		$(#question{QID} table td).css({ // Table cell heights
			'height': 'auto'
		});
 
		$(#question{QID} table.scs).css({ // Table border
			'border-bottom': '0 none'
		});
 
		$(#question{QID} .survey-question-help).css({ // Question help
			'display': 'none'
		});
 
		$(#question{QID} .subquestions-list).css({ // Margin around answers
			'margin': '0'
		});
 
		$(#question{QID} .answer).css({ // Padding around answers
			'padding': '0'
		});
	});
</script>

And add this to the second question:
<script type="text/javascript" charset="utf-8">
	$(document).ready(function() {
 
		$(#question{QID} table td).css({ // Table cell heights
			'height': 'auto'
		});
 
		$(#question{QID} table.scs).css({ // Table border
			'border-top': '0 none'
		});
 
		$(#question{QID} td.be).parent().css({ // Question text
		 'display': 'none'
		});
 
		$(#question{QID} .survey-question-help).css({ // Question help
			'display': 'none'
		});
 
		$(#question{QID} .subquestions-list).css({ // Margin around answers
			'margin': '0'
		});
 
		$(#question{QID} .answer).css({ // Padding around answers
			'padding': '0'
		});
	});
</script>



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

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now