right-justify entries in a constant sum box? | XM Community
Solved

right-justify entries in a constant sum box?

  • 29 March 2018
  • 5 replies
  • 56 views

Badge +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
icon

Best answer by TomG 29 March 2018, 21:52

View original

5 replies

Userlevel 7
Badge +27
```
jQuery("#"+this.questionId+" input.InputText").css("text-align","right");
```
Badge +3
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?
Userlevel 7
Badge +27
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.
Badge +3
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!!
Badge +3
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