Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Need help using drop down list to calculate fields

Avatar

Level 1

I am trying to use a drop down list to control how my field calculate. I have events packages that have multiple tiers. For example, Package One has (2) Tiers. Tier 1 costs $16 & Tier 2 costs $20. So based on the number of guests i want to be able to select the tier and it multiply and give me the total cost for the package. Ex: 2 Guests for Tier 1 = $32. Here is the code i have so far, it is placed under the change handler of the drop down list:

var costPerGuest = 16;

var tier = event.newText;

if (tier == "Tier 1"){

  costPerGuest = 16;}

else if (tier == "Tier 2"){

  costPerGuest = 20;}

Total.rawValue = String(Guests.rawValue * costPerGuest)

//Total.rawValue = DropDownList1.rawValue;

What happens is when I run this it will not change unless the number of guests will change. So for the example above, if i switch it to Tier 2 after selecting Tier 1, it will not change my Total from $32 to $40.

Any help would be greatly appreciated.

3 Replies

Avatar

Level 8

If you use the calculate event of the Total field you'll have more luck.  As soon as you change the dropdown or the guests field it will update

Avatar

Former Community Member

Hi,

I think ,you can use the event of EXIT event of dropdown list.

var costPerGuest = 0;

if (this.rawValue == "Tier1")

{

  costPerGuest = 16;

}

else if (this.rawValue == "Tier2")

{

  costPerGuest = 20;

}

else

{

................................

}

total.rawValue = Guests.rawValue * costPerGuest;

Hope this helps,

S,Candy.

Avatar

Level 1

Thank you Steve! This worked. I appreciate your help!