7 Replies Latest reply on Mar 13, 2017 3:10 PM by rrroxanne

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

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.

• ###### 1. Re: Custom script to create ticket sales. 1 for \$50 or 3 for \$100.

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?

• ###### 2. Re: Custom script to create ticket sales. 1 for \$50 or 3 for \$100.

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

• ###### 3. Re: Custom script to create ticket sales. 1 for \$50 or 3 for \$100.

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

• ###### 4. Re: Custom script to create ticket sales. 1 for \$50 or 3 for \$100.

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

• ###### 5. Re: Custom script to create ticket sales. 1 for \$50 or 3 for \$100.

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