# Why conditional logic doesn't work properly in my form?

• ngmsys
Asked on August 05, 2017 at 10:50 AM

But the conditional logic still doens't work well.

I need to realize quite simple algorithm: if option checked in the checkbox then I multiply a value of a field on some coefficient. I create a new rule: if checkbox contains then value of field1*on the coefficient. F.E. if client needs chosen design I increase the total price on 25%.

It doesn't work because:

a) every time when click on value of the checkbox the condition applied.

b) If target option is checked the condition is triggered as many times as the number of values selected in the checkbox.

Finally I need to realize certain logic. The coefficient should depends on which option is selected in the checkbox. I've tried to use a hidden field to save coefficient value but it doesnt' work because of bags that I described above.

I've used different types of checkboxes but the result is the same.

How can I implement required logic?

• Nik_C
Answered on August 05, 2017 at 03:11 PM

Could you please share the Form ID where you have this problem so we can check.

Thank you!

• ngmsys
Answered on August 07, 2017 at 03:15 PM
• Mike_G
Answered on August 07, 2017 at 04:30 PM

I would like to apologize for any inconvenience. It seems that your requirements are attainable, however, I believe it would be best if you can tell us every field in your form that is involved in the computation in order for us to get the total. If you can also let us know the exact steps that need to be taken on your form to get the total, that would be great.

We will wait for your response.

• ngmsys
Answered on August 08, 2017 at 03:40 PM

There are two calculated fields - input53 (min price) and input54 (max price).

The formula depends on values of check2 (input_26). There are options that influence on min and max price. Our goal is quite simple. We'd like to apply different coefficient depends on selected options.

• Nik_C
Answered on August 08, 2017 at 04:32 PM

If you were referring to this condition:

when I tested it worked, it calculated correctly:

And I entered 50 in Общая площадь, м2 field, so Сумма от was correct.

The same was for the other field Сумма до.

Now, since you need this field included in the calculation:

I'm afraid that it won't work since conditions don't recognize what is selected. So you could replace it with a regular check box:

And that will work with calculations, I just tested.

You can check my cloned version of your form: https://form.jotformpro.com/72195804786973

I set that if you select the first option, it will deduct the 10% from the Сумма от field.

Could that work for you by any chance?

• Nik_C
Answered on August 09, 2017 at 03:49 AM

Could you please tell us how Сумма от  and Сумма до should calculate when these fields are selected:

So we can try to create a working example?

Thank you!

• ngmsys
Answered on August 09, 2017 at 01:12 PM

Right now I exclude checkbox from formula because it doesn't work correctly. Instead of that I have to use input_64. To find error:

1. Just add condition "if checkbox2 contains "дизайн" (or any other value) then multiply field "Число" (input_62) on 1,5 (for example).

2. Make several tests, choose different configuration of checkbox values. See what's happened with coefficient (field Число (input_62)))

Additionally select and deselect checkbox values several time before submission. Again, see what's happened with coefficient.

• Nik_C
Answered on August 09, 2017 at 01:28 PM

So if any field is checked from here:

Insert 1.15 in Число field.
That will work with this condition:

And if you need to check each option individually you can use this condition:

If you need to calculate the coefficient separately for each option.

Here is my test form: https://form.jotformpro.com/72195804786973

Could that work for you?

Thank you!

• ngmsys
Answered on August 09, 2017 at 02:49 PM

1. Field should be multiplied on coefficient depends on options. F.E.

If option 1 selected that coef*x

If option 2 selected that coef+y

....

I see that you used other checkbox. I didn't try it.

It doesn't work for existing checkbox that I use in the form.

2. Select Разработка дизайн-проекта then unselect this option. The coef will not be changed. So, coef should be calculated on submission instead of click.

• Nik_C
Answered on August 09, 2017 at 03:21 PM

Yes, the existing field you used will not work so I replaced with regular check box field:

Since there you can use a condition like this:

And you can create such condition for each option when it is selected insert appropriate value in your Число field.

We could help you with creating such conditions just let us know which coefficient should go to Число field for which choice?

• ngmsys
Answered on August 13, 2017 at 04:46 PM

https://form.jotformeu.com/71133051103335

• Welvin
Answered on August 13, 2017 at 06:42 PM

Please allow me a few minutes to check this for you. It's the language that takes me time. I'll let you know.

• Welvin
Answered on August 13, 2017 at 07:15 PM

You may need to rebuild your conditional logic settings and target more fields instead of just one then sum them up to get the final amount/total.

Your conditional logic #1 and #2 (Total Area, M2) will create a conflict to the other conditional logic for the field "Укажите, пожалуйста,  какие услуги необходимо включить в смету.". Why? Because they are targeting the same field. The result field is the same.

Plus, you are using a checkbox for the "Укажите, пожалуйста,  какие услуги необходимо включить в смету." field. Each option has its own conditional logic to target the same field. Since it is a checkbox type, users may be able to select two or more options. The conditional logic won't work this way because it cannot detect which is which/what condition to follow.

My solution is the above, to add more fields. You have 7 options including the other, so add 7 more fields. One field equivalent to one option from the checkbox.

Here are your conditions showing the conflict:

These includes condition #1, #10, and #11.

I hope that helps. Let us know if you need further assistance.

• ngmsys
Answered on August 14, 2017 at 03:36 AM

1. Correct!

Total prices (Сумма от  (min price) and Сумма до (max price))  are calculated based on selected options. User could check all of them potentially. System must execute all these conditions in the order that is defined.

2. Anyway, just activate the last two conditions and see what's going on. It doesnt work eben you acivate only one formula if checked value that field1+number and record resul in the field 1.

• Chriistian
Answered on August 14, 2017 at 03:59 AM

I'm currently checking your form. Please allow me some time to further check the conditions. I'll get back to once I'm done.

• Chriistian
Answered on August 14, 2017 at 04:38 AM

I cloned your form and I noticed that there are only 3 conditions that are enabled on your form. The rest are disabled.

These three conditions are currently working on your form.

Regarding the other conditions, I'm not sure which of the last two conditions that you have enabled don't work. Could you please point them out for us?

If possible, please send us a screenshot image in this thread. Here's the guide on How to add screenshots/images to questions to the support forum?

As mentioned by my colleague, you need to add separate fields for the different options as their target fields to avoid condition conflicts.

Related Guide: How to Show or Hide Fields Base on User's Answer.

• jonathan
Answered on August 16, 2017 at 07:42 AM

May I ask why you cannot just delete the disabled conditions on the form?

Conditions #2 and #3 were actually conflicting since both have the same IF condition

To fix the conflicting conditions, need to change one of the IF rule.

Let us know if this will not work.

• ngmsys
Answered on August 18, 2017 at 03:07 AM

You didn't answer on my question. Please try to understand how it works before asnwer me.

I already explain that conditions # 1-3 have been created because the disabled conditions have not worked correctly.

At the same time condition #1-3 work absolutely correctly right now. These conditions should be applied only if the field  Общая площадь is filled.

1. Read all my comments regarding condition logic and bugs that we found.

2. Copy the form

2. Delete conditions #1-3

4. Implement test cases that I described above.

5.  Don't write me before you really test it

Again I spend too much time to implement pretty simple logic. If I can't do it in the nearest future  I will have to cancel subscription and change a supplier.

• Chriistian
Answered on August 18, 2017 at 04:55 AM

Sorry for the inconvenience.

Rest assured I have read all the comments and information in this thread. I also did the test cases as you mentioned.

Test-case 1

1 Deactivate all conditions.

2 Activate only one condition (last one).

3. Check the value. We get a fantastic value.

This condition below will not work because you are using the field as the coefficient and at the same time as the field which the result will be displayed.

The field that will be used as a coefficient should not be the same as the target field to avoid condition conflict.

Test-case 2

1 Deactivate all conditions.

2 Activate 2-3  conditions.

3. Check the values. It will wrong.

I did this test case and it is working on your form.

I came up with a conclusion that you want to get the results of multiple conditions/calculations in a single field like the fields (Сумма от and Сумма до) but unfortunately, this will not work because it will result in condition conflicts. Please try what we have suggested that you need to add separate fields for the results of every condition/calculations.

If still doesn't work or if I misunderstood your process, please clarify to us a bit more and please do get back to us.

• ngmsys
Answered on August 23, 2017 at 03:37 AM

You suggest me to add a hidden field for each option to save coefficients, am I right?

I think it's an inappropriate solution.

1. I have to spend a lot of time to do it. I pay for your service to make my life easy. You suggest me to spend time because you can not design and implement correct and transparent logic.
2. I need to add many unnecessary fields on the form just to make simple calculation.

Additionally, if I have more then 5 conditions it's quite difficult to work with it.

The better way to work with calculation is to make one condition where user can configure different scenarios.

If option 1 is value then formula 1

If option 2 is value then formula 1

If option 1 > value and option 3 > value then formula 1 then formula 3

....

Output field: Field X

So, conditions connected with calculation the same field should be grouped.

There are a lot of questions for your product team.

Finally, It seems that easier to swap form designer to get required capabilities.

• Nik_C
Answered on August 23, 2017 at 04:06 AM

We are sorry for this inconvenience, but I must agree with my colleague when it comes to using the same field in calculations and for result field. That will just not work. Calculations like that require additional field for the result, so you could simply add one more result field and point the calculation there.

I created a simple form that shows how the calculation you were trying to implement works:

So for test1 and sum, the numbers are 1 and 1, the result should be 1+1*2000 which is 2001 but it is showing 20001 because it can not save the middle score automatically.

The easy solution would be to create another sum field and point the result to go there:

If that couldn't work for you, we could forward to our backend team for an additional check.