Add a Constant Sum Row to a Side by Side Question | XM Community
Solved

Add a Constant Sum Row to a Side by Side Question

  • 8 March 2018
  • 9 replies
  • 191 views

Badge +2
I am looking to add a row that will calculate the running total and have a mandatory value for each column in a side by side table. Ideally, I would like each column to be able to have a different mandatory sum. Does anyone have code that could help with this? Thanks in advance.
icon

Best answer by Michael_Campbell_RedPepper 10 March 2018, 04:34

View original

9 replies

Userlevel 4
Badge +3
Yeah! What you do is the following:

How familiar are you with Javascript? If you're familiar, I can tell you in English - if not, let me know and I can code it out for you!

But select the field's ID, and put a JQuery `.change()` listener on the fields you want to total. When any of the fields changes, create and call a function that sums the values, and then use JQuery's `.val()` to set the value to the validation total.

A tip on ways to make it more fluid of a UX is to put a `setTimeout()` on the assigning of the sum so that the user has time to correct and then see the change reflected in the sum. I typically set mine to 300 Milliseconds.
Badge +2
Thank you! This is excellent.
Userlevel 4
Badge +3
@mpf2018 I'm glad it worked! Again, let me know if you need any elaboration.
Userlevel 2
Badge +1
Hi @Michael_Campbell_RedPepper. Sorry for reviving the question but I'd like to do this as well and am not as well-versed with Javascript. If I could get some elaboration on that I'd be very appreciative. Thanks!
Badge +3
@Michael_Campbell_RedPepper
Thank you. I'm also trying to do this, and don't have much familiarity with JavaScript. Could you please elaborate or script it out? Thank you!
Badge +3
Here's my side-by-side. I was able to remove the selections in the last row except for the last one under "Hours Claimed", and now want to have the last row/column entry calculate a sum of all the hours entered. Thanks!

!
Userlevel 1
Me too, I would like to do the same.
I also would like to do a side by side question with a constant sum. I don't know how to program Javascript. Can you help? Many thanks!!

Hello, I also would like to know how to program a constam sum in a side by side. :)

Leave a Reply