InfoPath 2010 getting sum for option button

564 views Asked by At

I have a survey in which I have 2 columns. Each question can either have the left column option button selected, or the one in the right column.

At the bottom of the 17 questions, I have the TOTAL values of each column. Each row of option buttons (left and right button are bound to the same control) has a value of 1 (left option button is selected) or 2 (right option button is selected).

I need to set rules in order to update the totals. What I have so far is: left option button:

If optButton = 1; leftTotal = leftTotal + 1
If optButton = 2; rightTotal = rightTotal + 1

This same rule is applied to all 17 questions. Now this works if the user goes through all questions and picks one option button on the first try. But if they need to switch their answer, the rules do not subtract to properly update the respective totals.

I tried doing this:

If optButton = 1; leftTotal = leftTotal + 1, rightTotal = rightTotal - 1

But that doesn't calculate the totals correctly either.

Please help! Really hard to explain this one in proper detail.

1

There are 1 answers

0
Kalpesh On

Lets say "LeftTotal" and "Righttotal" are two fields which shows the totals at the bottom. Set LeftTotal and RightTotal default value as 0. Now apply 2 rules on every option button set as - 1) if optButton = 1 then LeftTotal = LeftTotal + 1 2) if optButton = 2 then RightTotal = RightTotal + 1