Skip to main content
Participant
December 6, 2016
Question

Custom calculation javascript for complicated form

  • December 6, 2016
  • 2 replies
  • 950 views

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

This topic has been closed for replies.

2 replies

Inspiring
December 7, 2016

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.

try67
Community Expert
Community Expert
December 6, 2016

I don't quite follow... What's the price per ticket up to 16, and what's the price after that?

Participant
December 7, 2016

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

try67
Community Expert
Community Expert
December 7, 2016

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?