How to customize the question and answer option alignment? | XM Community
Skip to main content
Solved

How to customize the question and answer option alignment?

  • January 4, 2021
  • 13 replies
  • 513 views

Forum|alt.badge.img

I wish to emulate a online delivery platform for one of my project. For this, I wish to display an image on the left side and then answer choices (from qualtrics) on the right side. See the example given below.
b62c9753d7847526b15335cf06b01c57c7d124d8.pngHow can I create within Qualtrics? The respondent will pick one the three choices.

Best answer by TomG

Radio buttons aren't hidden with display:none in the theme. You need to trump the specific rule that is hiding them.
Try:
.Skin .MC .QuestionText input.test[type=radio] {
 position: static!important;
 opacity: 1;
 z-index: 1;
 height: auto;
 width: auto;
 overflow: auto;
 clip: auto;
}

13 replies

TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • January 4, 2021

The easiest way would be to emulate the online delivery platform in a three choice MC question text's html, hide the choice structure, and add event handlers to the radio buttons to select the corresponding MC choice when clicked.


Forum|alt.badge.img

Thanks for your reply Tom. Still this look complicated for me. Because, I wish to show both of them in the same page and it should not be activated by any clicks. I would like to have an image on the left and choice on the right like the image. People should be able to click and provide their response.


TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • January 4, 2021

Maybe I missed the point, but I assumed the three choices were two-day shipping, expedited shipping and free shipping and clicking one of those choices would answer the question. That's what the solution I outlined would do.


Forum|alt.badge.img

Since I am not well versed with Javascript. I didn't get your answer. I shall play around with it. Thanks for your time Tom.


Forum|alt.badge.img

https://www.qualtrics.com/community/discussion/comment/33063#Comment_33063Dear Tom,
I performed the task based on your suggestions. I have hid the choice structure using JavaScript and then I have shown the choices (defined by HTML). However, the radio buttons are not shown in the survey, do I miss something?
 

Situation text



 







Please indicate which option you would personally prefer:



 









   




JavaScript:

Qualtrics.SurveyEngine.addOnload(function()
{
jQuery("#"+this.questionId+" li.Selection").hide();


});


TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • January 6, 2021

The theme CSS is probably hiding the radio buttons since they normally aren't shown in modern Qualtrics themes. You can remedy that by adding a class to your radio inputs then adding a CSS rule to display that class as appropriate.


Forum|alt.badge.img

https://www.qualtrics.com/community/discussion/comment/33121#Comment_33121Hi Tom, sorry to bother you. I added class to the radio buttons and defined the class in CSS style sheet. However, still the problem persist!

.test {
display: inline !important;
}
 


TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • Answer
  • January 6, 2021

Radio buttons aren't hidden with display:none in the theme. You need to trump the specific rule that is hiding them.
Try:
.Skin .MC .QuestionText input.test[type=radio] {
 position: static!important;
 opacity: 1;
 z-index: 1;
 height: auto;
 width: auto;
 overflow: auto;
 clip: auto;
}


Forum|alt.badge.img

https://www.qualtrics.com/community/discussion/comment/33063#Comment_33063Dear Tom, I could not fix the event handler part. I have set value for the HTML radio button (that I created) and trying to check the radio button of the MC choice structure using the HTML radio button value.
I used this Java Script to test the value of the HTML radio button. It is working fine, now how should I use this value to get the MC choice structure of the question selected using event handlers?
Here is my code:
Qualtrics.SurveyEngine.addOnReady (function() {
$("input[name$='choice']").change(function() {
    var test = $(this).val();
if(test == 1) {
      alert('yes');
//your code to select MC option 1
        } 
   else if (test == 2){
   alert('no');  
//your code to select MC option 2
   }
});
 });


TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • January 13, 2021

In Qualtrics $ is prototypejs, not jQuery. Change $ to jQuery.


Forum|alt.badge.img

I tried my best but I failed! What is the issue with my jQuery code to

Qualtrics.SurveyEngine.addOnChange (function() {
jQuery("input[name$='choice']").change(function() {
//choice is from the HTML
    var test = jQuery(this).val();
if(test == 1) {
      alert('yes');
       jQuery('input[name=QR~QID141~8]:checked', '.ChoiceStructure').val() //this one does not work but alert works!
        } 
   else if (test == 2){
   alert('no');
      jQuery('input[name=QR~QID141~9]:checked', '.ChoiceStructure').val() ///this one does not work but alert works!
   }
});
 });


TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • January 13, 2021

You have a number of issues: wrong selectors, val() is wrong function, and tildes need to be escaped. Try:
if(test == 1) {
  jQuery('.ChoiceStructure input').first().prop("checked",true);

else if (test == 2) {
  jQuery('.ChoiceStructure input').last().prop("checked",true);
}


Forum|alt.badge.img

Thanks Tom. The above code did work. However, I fixed it with this code.

Qualtrics.SurveyEngine.addOnReady (function() {

jQuery("input[name$='choice']").click(function() {
    var test = jQuery(this).val();
    jQuery("div.image").hide();
    jQuery("#carbon"+test).show();
   if(test == 1) {  
radiobtn = document.getElementById("QR~QID141~8");
       radiobtn.checked = true;
        } 
   else if (test == 2){
radiobtn = document.getElementById("QR~QID141~9");
       radiobtn.checked = true;
    }

});
  });