Copy link to clipboard
Copied
I'm trying to create a form that allows me to calculate the total of ticket sales.
The tickets are 1 for $50, or 3 for $50.
Any help with this would be greatly appreciated. I have no knowledge of JavaScript, so I'm attempting to figure this out blindly.
OK... Then you can use this code as the custom calculation script of the Price field (adjust the name of the Tickets field in the code, if necessary):
var qty = Number(this.getField("Tickets").value);
var price = Math.floor(qty/3)*100 + ((qty%3)*50);
event.value = price;
Edit: fixed a small mistake in the code above...
Copy link to clipboard
Copied
Your title and your text are conflicting... Is it $100 for 3 tickets or $50? Also, are these the only options for the number of tickets that can be bought?
Copy link to clipboard
Copied
Thank you for your reply.
Sorry for the confusion, I should've double checked what I was writing before sending it. It's supposed to be each ticket for $50, or 3 tickets for $100. So if 6 are purchased, it would be $200... but, if they purchased 4 tickets, it would be $150...
Copy link to clipboard
Copied
OK, that's what I thought. However, are you sure about that? That would mean that the price of 5 and 6 tickets is the same ($200)...
Copy link to clipboard
Copied
Yes, that would be correct. 2 would be the same as 3. 5 the same as 6.
Copy link to clipboard
Copied
OK... Then you can use this code as the custom calculation script of the Price field (adjust the name of the Tickets field in the code, if necessary):
var qty = Number(this.getField("Tickets").value);
var price = Math.floor(qty/3)*100 + ((qty%3)*50);
event.value = price;
Edit: fixed a small mistake in the code above...
Copy link to clipboard
Copied
Sorry, made a small mistake. Make sure you copy the edited code...
Copy link to clipboard
Copied
Thank you! That worked perfectly. Thank you so much, it's greatly appreciated!
Find more inspiration, events, and resources on the new Adobe Community
Explore Now