How to move answer boxes | XM Community
Skip to main content
Question

How to move answer boxes

  • April 15, 2020
  • 3 replies
  • 57 views

Forum|alt.badge.img+1

I have a single question with four answer options displayed horizontally. I am trying to move them so that they align with an HTML table which appears directly above.
I have managed to successfully use this syntax to move the first and last answer boxes around.
Qualtrics.SurveyEngine.addOnload(function()
{
var el1 = $(this.questionId).select('label.SingleAnswer').first();
el1.style.marginLeft = "80%";

    var el4 = $(this.questionId).select('label.SingleAnswer').last();
    el4.style.marginLeft = "200%";
});
How do I select the 2nd and 3rd answer boxes? I've tried $(this.questionId).select('label.SingleAnswer').eq(1); for the second, but this doesn't work.

3 replies

rondev
Level 6 ●●●●●●
Forum|alt.badge.img+22
  • Level 6 ●●●●●●
  • April 15, 2020

Try using below:
var el2 = jQuery("#"+this.questionId).find('label.SingleAnswer:eq(1)');
var el3 = jQuery("#"+this.questionId).find('label.SingleAnswer:eq(2)');


Forum|alt.badge.img+1
  • Author
  • April 16, 2020

Thanks rondev, but unfortunately that didn't run. I also tried the following, but they didn't work either.
 $(this.questionId).find('label.SingleAnswer:eq(1)');
 $(this.questionId).select('label.SingleAnswer:eq(1)');


TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • April 16, 2020

@TriciaB,

  1. You can't intermix Prototypejs ($) and jQuery. .find() and .eq() aren't prototypejs functions. They only work on jQuery objects.

  2. rondev's code is correct, but I think you have the wrong element. A horizontal MC uses a table, so you want to align the table cells. You would probably be better off adding/moving everything into the same table.