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

right-justify entries in a constant sum box?

  • Mar 29, 2018 6:38 PM UTC
  • 5 replies
  • 135 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.
View original

5 replies

TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • Mar 29, 2018 6:53 PM UTC
``` jQuery("#"+this.questionId+" input.InputText").css("text-align","right"); ```

MaryHoban
Forum|alt.badge.img+3
  • Author
  • Mar 29, 2018 7:28 PM UTC
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 ●●●●●●●●
  • Answer
  • Mar 29, 2018 7:52 PM UTC
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
  • Mar 29, 2018 8:25 PM UTC
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
  • Mar 29, 2018 8:27 PM UTC
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!!