What is JotForm?
JotForm is a free online form builder which helps you create online forms without writing a single line of code. No sign-up required.
At JotForm, we want to make sure that you’re getting the online form builder help that you need. Our friendly customer support team is available 24/7.
We believe that if one user has a question, there could be more users who may have the same question. This is why many of our support forum threads are public and available to be searched and viewed. If you’d like help immediately, feel free to search for a similar question, or submit your question or concern.
Use the Max() function in form calculator multiple timesAsked by CommissionTogether on January 17, 2017 at 12:21 PM
I am trying to build a booking system for an event with the following criteria.
Multiple people will book in under one transaction (ideally unlimited number but a max of 10 would be fine if needed)
I have tried asking how many people to book and then skipping a number of pages to limit the input pages which works fine however:
Each delegate being booked in selects camping / not camping (with different prices) and then type of delegate: adult, concession, child etc (all with different prices) and then finally if they are an adult or concession they can choose to volunteer and get a discount off their booking.
The discount is only applied to that individual persons ticket and the value must not be less than zero so I have been using the MAX() function but this only works if I use it only once on the entire form. I need to be able to use it on each page of a form.
Below is what I understand so far after creating a clone version of your form and inspecting it.
I see that you have set calculation values for each option in the Ticket type, Delegate type, and Serving option.
And base on the calculation field (Form Calculation widget) wizard, I believe "Serving option" is what you are referring to as discount, is that correct?
I also noticed that the discount is only applicable to "Adult" option from the Delegate type field since the Serving option field only shows (conditionally) if Adult option is selected.
Having said that, since the highest calculation value set for the Serving option (discount) is 100 (which is if Stewarding option is selected) and the calculation value set for the Adult option in the Delegate field type is also 100 and the Ticket type are 50, 20, and 0, respectively, in what instance would your respondents be able to get a value of less than 0 (zero) for the calculation?
Please note that the max() math function will find the highest value among a set of numbers separated by comma(s).
Please see this sample form: https://form.jotform.com/70165528767970
Check #11 of this guide: Form-Calculation-Math-Function-Reference
Maybe a little bit of information would help us understand what you're trying to do.
Looking forward for your response.
The values in the adult ticket price and the discount are just random numbers for testing purposes.
It would appear that the issue is that whilst I had put a "," in the max function I also needed to click on it to make it go brown and then on it again to make it go black and make it become "active". I think this might be a bug or at least not obvious behaviour!
I can only assume that you were able to make your form work since you have already determined where the issue is, is that correct?
With regards to the behaviour of any text (string) entered/typed in the calculation area of Form Calculation widgets, it will always be in brown color (text) initially until clicked to become black (number). Anything that is typed in the computatoin area are being recognized as text by default and it is not a bug. You just have to click it for it to be recognized as part of the equation and not as a text (string).