Welcome, Guest
Username: Password: Remember me

TOPIC: Dual Scale with subquestions in center?

Dual Scale with subquestions in center? 3 years 11 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.

Desired_Behavior.png


Thanks!
The administrator has disabled public write access.

Re:Dual Scale with subquestions in center? 3 years 11 months ago #51623

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5351
  • Thank you received: 299
  • Karma: 250
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.

Re:Dual Scale with subquestions in center? 3 years 11 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: 3 years 11 months ago by johnichiban.
The administrator has disabled public write access.

Re:Dual Scale with subquestions in center? 3 years 11 months ago #51636

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5351
  • Thank you received: 299
  • Karma: 250
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.

Re:Dual Scale with subquestions in center? 3 years 11 months ago #51702

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4297
  • Thank you received: 811
  • Karma: 374
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.164 seconds
Donation Image