Copy link to clipboard
Copied
Hello,
I have a booking form with some complicated calculations that requires 'if' and 'then' custom javascript.
The form offers tickets at $350 per person, up to 16 people, with up to 4 additional tickets for $100 each. I tried some script from a previous form but I just don't know how to customise the script to take the initial 16 tickets into account, and then any additional number of tickets after that.
var numTix = Number(this.getField("QTY1").value);
if (numTix==0) event.value = 0;
else if (numTix==1) event.value=350;
else event.value = 350+((numTix-1)*100);
Any suggestions would be very greatly appreciated.
Thanks,
Kate
Copy link to clipboard
Copied
I don't quite follow... What's the price per ticket up to 16, and what's the price after that?
Copy link to clipboard
Copied
Hi try67,
The ticket price is $300 up to 16 and then $100 after that (but only an additional four tickets can be bought at the $100 price mark). So you can effectively purchase 20 tickets in total for $5,200
Thanks so much.
Kate
Copy link to clipboard
Copied
And what if the user enters a number bigger than 20 into the number of tickets field? Or did you apply a validation that prevents that?
Copy link to clipboard
Copied
Oh I hadn't got that far, but I will now. Thanks for reminding me ![]()
Copy link to clipboard
Copied
OK, well the code will be something like this:
var numTix = Number(this.getField("QTY1").value);
if (numTix<=16) event.value=300*numTix;
else event.value = (16 * 300) + ((numTix-16)*100);
Copy link to clipboard
Copied
Thank you so very very much! That's fantastic try67, works perfectly. You really saved my bacon ![]()
Copy link to clipboard
Copied
Also, if it's possible for the user to specify a number greater than 20, less than 0, or a non-integer, what should happen? If you're using a dropdown that limits the possible values to 1 through 20, please ignore this question.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more