right-justify entries in a constant sum box? | XM Community
Skip to main content
Solved

right-justify entries in a constant sum box?

  • March 29, 2018
  • 5 replies
  • 85 views

MaryHoban
Forum|alt.badge.img+3
I'm hoping that someone might have a javascript so that entries in a constant sum question are right-justified, rather than centered in the box? TIA! - Mary

Best answer by TomG

Click on the cog to the left of the question, then select Add JavaScript... Under the addOnload section paste it in place of the "/\\*Place your JavaScript here to run when the page loads\\*/" comment.

5 replies

TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • 6084 replies
  • March 29, 2018
``` jQuery("#"+this.questionId+" input.InputText").css("text-align","right"); ```

MaryHoban
Forum|alt.badge.img+3
  • Author
  • 6 replies
  • March 29, 2018
Thanks @TomG. I need more specific guidance. Exactly where do I put this? Does it go at the end of the box in the HTML view of the question?

TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • 6084 replies
  • Answer
  • March 29, 2018
Click on the cog to the left of the question, then select Add JavaScript... Under the addOnload section paste it in place of the "/\\*Place your JavaScript here to run when the page loads\\*/" comment.

MaryHoban
Forum|alt.badge.img+3
  • Author
  • 6 replies
  • March 29, 2018
I've already got this in the JavaScript box to make the boxes wider: Qualtrics.SurveyEngine.addOnload(function() { var inputWidth = "80px"; $(this.questionId).select('.SumInput').each(function(name, index) { name.style.width = inputWidth; }); $(this.questionId).select('.SumTotal').each(function(name, index) { name.style.width = inputWidth; }); $(this.questionId).select('.InputText').each(function(name, index) { name.style.width = inputWidth; }); }); Can you show me where exactly to add: jQuery("#"+this.questionId+" input.InputText").css("text-align","right"); I've tried it in a couple of different ways - no luck. Thank you!!

MaryHoban
Forum|alt.badge.img+3
  • Author
  • 6 replies
  • March 29, 2018
Oh my gosh. I just got it. This worked: Qualtrics.SurveyEngine.addOnload(function() { var inputWidth = "80px"; $(this.questionId).select('.SumInput').each(function(name, index) { name.style.width = inputWidth; }); $(this.questionId).select('.SumTotal').each(function(name, index) { name.style.width = inputWidth; }); $(this.questionId).select('.InputText').each(function(name, index) { name.style.width = inputWidth; }); jQuery("#"+this.questionId+" input.InputText").css("text-align","right"); }); Thank you so much, @TomG, for your help and patience!!