-
NolasolAsked on November 24, 2014 at 10:27 AM
Hello,
I'd like to set up a condition for update a field (named as FINAL RESULT) value on form as below:
FORM CALCULATION1 (this calculation works correctly and I see the result)
FORM CALCULATION2 (this calculation works correctly and I see the result)
then
FINAL RESULT (a textbox) => value of this field would be updated by a condition:
IF FORM CALCULATION1 = FORM CALCULATION2 THEN FINAL RESULT = "ALPHA"
IF FORM CALCULATION1 <> FORM CALCULATION2 THEN FINAL RESULT = "BETA"
when both FORM CALCULATION1 and FORM CALCULATION2 would be a text string also (not only a number).
In the JotForm's window of condition, I can set up it until
IF FORM CALCULATION1 IS EQUAL TO ...
and then a text field appears and I can't insert an other field's name here...
(Because I can't predict, what is the actual value of FORM CALCULATION2 when user fills the form, I also can't prefill any value for condition...)Can you give me any trick to do it? :-)
Thanks
Noemi
-
KadeJMReplied on November 24, 2014 at 11:28 AM
I see you are trying to have a field calculation updated on your jotform as a final result of two other calculations it looks like.
I would first recommend reviewing this guide here http://www.jotform.com/help/268-How-to-Insert-Text-or-Mathematical-Calculation-into-a-field-using-a-Condition. This will allow you to grab two other calculations from the first two inputs and then you could send them to your final field as a result.
If you need more help though please provide us with a link to the jotform you are working on?
-
NolasolReplied on December 1, 2014 at 7:24 AM
Hello KadeJM,
sorry for my latish answer but I had to solve other troubles in JotForm :-)
I visited your guide but - I don't understand why - it's not working for me :-)
The situation is I can't compare two fields in the line of condition.
Following your example in picture, if I set up a field after "IF" expression, then I get options as dropdown list to select a relationship (equal to, contains, greater than etc.), but the other field is only an empty text field, instead of a list of fields.
Let's see in your picture:In my own window an empty texbox appears where a "product 1" field appears in your picture.
There I can't select any other field and if I would write manually "product 1" or "{product 1}" or any other syntax, it doesn't work.My own form contains fields with calculated numeric values. Then I need to compare two fields of them and depends on result (<, >, =) I would update a value of a field conditionally with text.
For example:If PRODUCT1 greater than PRODUCTS2 then update value of PRODUCT_DATA field to "GREATER".
Now I can't do it, because I can't compare PRODUCT1 to PRODUCT2...
I'm only able to compare PRODUCT1 to a manually written value, but it's not a solution for me.Can you help me? :-)
Thanks
Noemi
-
CharlieReplied on December 1, 2014 at 10:10 AM
Hi Noemi,
Unfortunately, I believe this is not a function available in our form builder right now. But I can submit a feature request to our developers and technical team so that they can take a closer look and see if it can be implemented. Please do take note that I can't give an exact date to when this will be updated.
For a workaround, we can do a manual input of that function if you will be embedding your form in a website, we can use the form's full source code and manually input a function to compare, here's a javascript code that might work:
var fistInput = document.getElementById("first").value;
var secondInput = document.getElementById("second").value;
if(firstInput === secondInput)
{ They are the same }
else if(firstInput > secondInput)
{ First is greater }
else
{ Second is greater }
I hope this helps. Let us know if you need further assistance on this.
Thank you.
-
NolasolReplied on December 1, 2014 at 10:20 AM
Hi Charlie,
thanks for your suggestion and example.
I made a "THIRD_FIELD" and its value is = 'PRODUCT1 - PRODUCT2'
Then this field will be negative, positive or zero.
In our condition I tried to make a comparison to this one field"If THIRD_FIELD is greater than 0 then ..." but if I set up "THIRD_FIELD" in the first dropdown of condition, I don't get option 'is greater than' but only 'contains, does not contain, equal etc. :-)
It was the second stop of my work :-)Now I found a solution,
"If THIRD_FIELD contains "-" then ..."
"If THIRD_FIELD starts with 0 then ..."
and finally
"If THIRD FIELD does not contain "-" AND does not start with 0 then ..."It's little bit more complicated workaround than a simple comparison in a conditional calculation window :-) , but it is working now :-)
Because of - at this moment - I'm not an expert of PHP programming (I'd like to learn it later), I try to avoid injecting any code into my form :-)
Thanks for your help
and I'm waiting for your news about implementing this so 'standard' function (as KadeJM's previous screenshot shows JotForm could do it also!)...
Friendly
Noemi
-
CharlieReplied on December 1, 2014 at 10:47 AM
Hi Noemi,
Thanks for updating us. Yes, the condition does allow us to set this kind of rules, although this time it's missing a function to where we can compare directly two different input fields or to others.
I'm glad you found a more suitable workaround without editing the full source code. It's nice that we can learn a lot of things specially from workarounds, there's always room to add new skills and knowledge :)
Regarding the added function, I've already escalated this to our developers and opened up a feature request ticket. We will receive a notification from them when there is an update.
Thank you.