Check out the LimeSurvey source code on GitHub!

Dual Scale with subquestions in center?

More
6 years 3 months ago #51618 by johnichiban
Is possible to create a dual scale question with the subquestions displayed in between the two header scales instead of on the left? A mock-up of the desired behavior is attached.



Thanks!
Attachments:

Please Log in to join the conversation.

More
6 years 3 months ago #51623 by Mazi
Please search the forum and also have a look at manual -> workarounds, I think I saw that once, created by some Javascript coding.


Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)survey-consulting.com'"

Please Log in to join the conversation.

More
6 years 3 months ago - 6 years 3 months ago #51632 by johnichiban
Here is one possible approach that works. I would like a more elegant way of hiding the original answer text, this is a bit hacky.

<script type="text/javascript" charset="utf-8">

$(document).ready(function(){

dualCenter(questionID);

function dualCenter(qID) {
$('#question'+qID+' table.question tbody tr').each(function(i){
$(this).find('td.dual_scale_separator').replaceWith($('<td class=answertext>'+$('th', this).text()+'</td>'));
$('<td class=answertext style=background-color:' + rgb2hex($(this).css('background-color')) + '> </td>').prependTo(this);
$(this).find('th').hide();

});
}

function rgb2hex(rgb) {
rgb = rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
function hex(x) {
return ("0" + parseInt(x).toString(16)).slice(-2);
}
return "#" + hex(rgb[1]) + hex(rgb[2]) + hex(rgb[3]);
}


});

</script>
Last Edit: 6 years 3 months ago by johnichiban.

Please Log in to join the conversation.

More
6 years 3 months ago #51636 by Mazi
Thanks for sharing your solution!


Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)survey-consulting.com'"

Please Log in to join the conversation.

More
6 years 3 months ago #51702 by tpartner
Nice DOM manipulation :cheer:

Try this to hide the original text:
$('th', this).text('');

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.

Imprint                   Privacy policy         General Terms & Conditions         Revocation information and revocation form