Shifting / repositioning multiple choice answers | XM Community
Skip to main content
Solved

Shifting / repositioning multiple choice answers

  • October 9, 2023
  • 6 replies
  • 67 views

Forum|alt.badge.img+1

Hi, I want to shift the answers so they line up with the choices:

I want to do this for 80 questions that are formatted identically. Can you help me please?

Best answer by TomG

Classic is the best layout for what you want to do.  Your JS might have an error which stops it from running. I’m not sure what else you’ve done, because if your choices are Horizontal they should take up 100% of the width.

Anyway, your JS could be something like this:

Qualtrics.SurveyEngine.addOnload(function() {
jQuery("#"+this.questionId+" .ChoiceStructure tr").prepend("<td></td>").find("td").each(function() { this.setAttribute("width","25%"); });
});

 

6 replies

TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • 6084 replies
  • October 9, 2023

The best option would be to include the price ($9.99/lb) in the choice label (Product A). That eliminates the need for a Price/lb label.

An alternative is the use JS to move the choices inside your price table (I’m assuming it is a table).


Forum|alt.badge.img+1
  • Author
  • 3 replies
  • October 9, 2023


@TomG

It is a png image with a ton of stuff above the price, so the answers just need to be shifted. I’ve been reading up on the forum but cannot find a JS code that shifts the multiple choice answers to the right like I need it to.


TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • 6084 replies
  • October 9, 2023


@TomG

It is a png image with a ton of stuff above the price, so the answers just need to be shifted. I’ve been reading up on the forum but cannot find a JS code that shifts the multiple choice answers to the right like I need it to.

Assuming the choices are horizontal, if you make the width of the image 100%, then you can use JS to add a table cell before the first choice and make the cell widths match the percentage widths of the items in the image (e.g., 25% each). 


Forum|alt.badge.img+1
  • Author
  • 3 replies
  • October 10, 2023

Thank you @TomG , the image is 100%. How do I add a table cell? 

It seems like whatever I add in the Javascript code does not change anything whatsoever. Does it matter what layout I’m using? I’m using Classic right now. I was using Simple before but apparently it does not allow for custom code.


TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • 6084 replies
  • Answer
  • October 10, 2023

Classic is the best layout for what you want to do.  Your JS might have an error which stops it from running. I’m not sure what else you’ve done, because if your choices are Horizontal they should take up 100% of the width.

Anyway, your JS could be something like this:

Qualtrics.SurveyEngine.addOnload(function() {
jQuery("#"+this.questionId+" .ChoiceStructure tr").prepend("<td></td>").find("td").each(function() { this.setAttribute("width","25%"); });
});

 


Forum|alt.badge.img+1
  • Author
  • 3 replies
  • October 10, 2023

@TomG  you are a kind and intelligent soul. Thank you much!