Update repeater with dynamically loaded text field

Hi Guys,

I am building a mobile booking app for a flight company as part of a project. I am on the Results Page. Anyway, I use a special formula to dynamically calculate the prices based on trip time, distance, and price variation… This works fine… Ideally, I would like to capture an average of these prices in a global variable so that I can use for another repeater. To this effect, I have tried updating the item.price by making the price text field a local variable and then assigning it to the item.price column but it doesn’t seem to be working. Once I figure this out, then I can sum the numbers and later the average. Here are some screenshots:

image



thoughts?

I’ve done something similar before. I made a shopping cart with a repeater and then wanted to calculate tax on the sum of all the prices. I did you by using the OnItemLoad event of the repeater to add the value of the item onto a global variable ( total = total + item.value ) and then I had a special case for the last item in the repeater to do the calculation on the global variable after it added its value. Use the item.isLast() function in a condition on that case to test for the last item.

In your case you could even dynamically divide the global variable by the number of rows in the repeater so you don’t have to hard code that value if the number of rows ever changes.

Thanks I figured it out with some help. Pretty much I had to set 4 conditions.

  1. SET PRICEAVG Global to 0: IF TRUE: Set Price Avg to 0
  2. Calculate and populate price text field in repeater: IF TRUE Calculate the price based on formula that draws from aspects of my repeater (e.g. item.price, item.traveltime etc) for the text field which I want to sum across repeater items.
  3. CALCULATE SUM OF PRICES: IF TRUE; make Price Field into local variable (e.g. getPrices) and then define PRICEAVG Global to: [[PriceAvg + getPrices]]
  4. TAKE THE AVERAGE If item.last is true, then PriceAvg = PriceAvg/item.count

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