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.
How to use conditions if a calculated field value is less than zero (negative)Asked by fhpw on March 10, 2017 at 08:17 AM
I have a reservation form that allows for payment by credit card or check. To have one payment calculation I used conditional logic to calculate amount due using Payment Calculation. For the Payment Gateway, The amount is passed using "PayPal Input". Reservation Total 1 is for PayPal, Reservation Total 2 is for Check/Cash.
All conditions are working except if the value is negative. The only time the value would be negative is if a paid sponsor registers for fewer seats then the total amount allowed. Sponsors receive a code, so this issue will only occur if Sponsor is selected.
For example, a sponsor registrant reserves (1) seat. However, the sponsor package allows for 2 seats and registrant enters 2 under sponsored seats instead of (1), then the calculated value is $-100.00 under cash/check payment and converts to $100.00 for PayPal.
This issue only occur if a sponsor registrant enters total allowed seats instead that is greater than the number of actual reserved seats. If the sponsor registrant enters 2 seats and the number of sponsor seats is 2, it works.
I have attempted different conditions with value less than 0, but it does not change the negative value.
How do I resolve the negative value issue so that if the number of sponsor seats is greater than the reserved seats, the reservation total is $0.00?
Is it possible to use conditions that Sponsored Seats cannot be more than Total Seats? For example, if Total Seats is less than sponsor seats, then sponsor seats is equal to total seats?
Alternatively, would multiple calculation fields with conditional logic to insert 0.00 into the final totals work?
Calculation fields will be hidden, only Reservation Total will show based on Payment Type. The first Reservation Total is for PayPal, the second Reservation Total is for Cash/Check
Payment fields make the assumption that you would not pass a negative value. Due to this, any negative values are converted to positive so they can be processed.
The easiest thing to do would be to have a condition set up where if the circumstances are that which would produce a negative value, the whole equation would be multiplied by 0. Setting up a number field to conditionally produce 1 if sponsor seats is less than or equal to total seats. Or, if sponsor seats is greater than Total seats you would conditionally update the field with a value of 0. You could then take that field and multiply it by your whole equation.
This way, if sponsor seats ever exceeds the number of total seats, your equation would be multiplied by 0 and produce a cost of 0.