right-justify entries in a constant sum box? | XM Community
Skip to main content
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
```

jQuery("#"+this.questionId+" input.InputText").css("text-align","right");

```
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?
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.
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!!
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!!

Leave a Reply