Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

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

New Here ,
Mar 13, 2017 Mar 13, 2017

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.

TOPICS
Acrobat SDK and JavaScript
497
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Mar 13, 2017 Mar 13, 2017

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

Translate
Community Expert ,
Mar 13, 2017 Mar 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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 13, 2017 Mar 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...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 13, 2017 Mar 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)...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 13, 2017 Mar 13, 2017

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 13, 2017 Mar 13, 2017

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 13, 2017 Mar 13, 2017

Sorry, made a small mistake. Make sure you copy the edited code...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 13, 2017 Mar 13, 2017
LATEST

Thank you! That worked perfectly. Thank you so much, it's greatly appreciated!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines