How can I multiply number in repeater, clicking on plus


#1

Hi,
I am begginer in Axure and have a problem:

I have repeater with items, all of them have their own prices, which has its own column in repeater. Another repeater is built for showing items, which are chosen by user:

the price of each item is shown correctly when i am adding it, but when I am click “plus” it doesn’t want to be increased by its value.

I have also added global variables: number of products and priceofproduct, i have something like this
[[NumberOfProducts*PricePerProduct]] and it’s target is total and when default value of priceofproduct is 0.00 I tried to do [[PricePerProduct+Item.price]], just adding the prices from repeater to 0.00, but it doesn’t work. On total it shows 0 or NaN when i choose 3 items.

I just want when i click on plus its multiply the price of every item. (when i change default value in global variances on 50 it works good, I think that I am doing something wrong with [[PricePerProduct+Item.price]], but I don’t know what.


#2

It would help immensely if you could post your .rp file. Hard to tell just how you’ve set this up in your repeater, why and what you are doing with your global variables and what all.

I don’t understand the logical difference between PricePerProduct and Item.price, other than one is a global variable and the other is a cell in your repeater sheet --could you elaborate? Why would these be different values and why would adding them result in something meaningful? Why is the global variable required?

So, you have a column for “price” --do you also have a column for “count” (number of items shown between your minus and plus buttons in your example)? If so, you would want to update “This row” whenever the plus or minus buttons were clicked, changing the value of the “count” column and thus triggering the calculation of the “Total” value by multiplying [[Item.price * Item.count]] --and do this in the OnItemLoad event for the repeater. Otherwise, you could just increase the number (e.g., from 1 to 2) and multiply that by the price, as in, [[(Count.text * Item.price).toFixed(2)]] to get the total.


#3

PricePerProduct is my global variable:
image

Item. price is name of my one column with all prices ( i have it in different language but i mean this in red rectangle)

I think when I assign default value 0 to PricePerProduct and when I add item.price the global variable will save the new price with addition and next when i multiply it by NumberOfProducts shows multiplied price in basket.

Ok, so you told me that i need to add another column with count:
image
i add it next to price in the first repeater with all my items.
In my second repeater which is basket in my shop i have only coumns not rows so when i adding a thing from my list it shows every of them:
image

I don’t understand in which repeater i need to do [[Item.price * Item.count] in total? if i have this two in my repeater with list


#4

I don’t understand why you have two repeaters, but you would want to perform the calculation in the repeater in which you want to see the result–so the repeater you show in your last screenshot.

There are two ways to do this: (1) use column values and perform calculations in the OnItemLoad event, or (2) perform calculations only on the repeater item (e.g., the minus and plus buttons). In this recent thread, @UXProtoTyper nicely demonstrates these two approaches and explains benefits and drawbacks of each.


closed #5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.