Welcome, Guest
Username: Password: Remember me

TOPIC: Dual Scale with subquestions in center?

Dual Scale with subquestions in center? 4 years 9 months ago #51618

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!

This message has an attachment image.
Please log in or register to see it.

The administrator has disabled public write access.

Dual Scale with subquestions in center? 4 years 9 months ago #51623

  • Mazi
  • Mazi's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 5725
  • Thank you received: 333
  • Karma: 255
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)limesurvey.org'"
The administrator has disabled public write access.

Dual Scale with subquestions in center? 4 years 9 months ago #51632

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: 4 years 9 months ago by johnichiban.
The administrator has disabled public write access.

Dual Scale with subquestions in center? 4 years 9 months ago #51636

  • Mazi
  • Mazi's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 5725
  • Thank you received: 333
  • Karma: 255
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)limesurvey.org'"
The administrator has disabled public write access.

Dual Scale with subquestions in center? 4 years 9 months ago #51702

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 5087
  • Thank you received: 1046
  • Karma: 438
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.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.144 seconds