How to make local variables have those value only when the variables on selected state

HI, I have some troubles with local variables.

how can I do with in function(fx) to variables only have those value when is on selected state. like such as var1.selected? I tried this but did not work. is there any way to make this work?

for example, var1, var2, var3… is button that have integer values.
and I like to show the sum of the only selected ones.
[[var1]]+[[var2]]+[[var3]]+…+[[varN]]

and I like to know how to limit the sum of variables to the special state, such as positive, lesser than 100 or something like that.

The best way to start using logic with those variables is by structuring cases tied to events from the UI. That’s where Axure put their features for doing if/else tests that can easily see conditions like “field.isSelected” to match your thinking.

Hi!

Here are three different methods on three pages of a file.

The first one takes advantage of the value FALSE evaluating to 0 when placed in a mathematical expression (whereas TRUE evaluates to 1 in such an instance). So we put the selected value of each checkbox (either TRUE or FALSE) into a local variable and multiply that by the text of the associated field text (also in a local variable) and then sum each (checked * text) product:

[[LVAR_field1 * LVAR_check1 + LVAR_field2 * LVAR_check2 + LVAR_field3 * LVAR_check3]]

The second simply uses OnItemLoad of a repeater in traditional fashion. OnItemLoad evaluates once per row in the repeater. Any update of the repeater’s dataset will cause OnItemLoad to re-evaluate all rows.

The third uses the “listener method” for summing. (Google “axure repeater listener method” for many examples of how this works, and look at the “comments” in the code.)

Live sample

File: sum checked rows.rp (333.5 KB)