Skip to main content
rrroxanne
Participant
March 13, 2017
Answered

Custom script to create ticket sales. 1 for $50 or 3 for $100.

  • March 13, 2017
  • 1 reply
  • 561 views

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.

This topic has been closed for replies.
Correct answer try67

Yes, that would be correct. 2 would be the same as 3. 5 the same as 6.


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...

1 reply

try67
Community Expert
Community Expert
March 13, 2017

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?

rrroxanne
rrroxanneAuthor
Participant
March 13, 2017

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...

try67
Community Expert
Community Expert
March 13, 2017

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)...