Calculation not triggering

  • Deralict
    Asked on January 30, 2015 at 12:23 AM

    On my form at the bottom I have a series of checkboxes ("occupations_") following the heading "Are you currently getting paid to engage in any of the following occupations?" A calculation field "Occupations_result" immediately following these checkboxes receives the value of these checkboxes and each checkbox has a calculation value of 1 (so if three boxes are checked, "Occupations_result" has the value 3. Finally, another checkbox ("Occupations_none") following the calculation field is set up with some conditional logic as follows:

       1. If checked, (equal to "None of the Above") SHOW "occupations_".

       2. If checked, (equal to "None of the Above") INSERT 0 into "Occupations_result".

       3. If UNchecked (not equal to "None of the above") INSERT the value of occupations_ into "Occupations_result".

    The problem is that condition #3 is not executing. For example:

    I check three of the checkboxes of "occupations_". The value of "Occupations_result" is set to 3. I check "Occupations_none". The other checkboxes are hidden and "Occupations_result" is set to 0. I then uncheck "Occupations_none". The other checkboxes re-appear but......................the value of "Occupations_result" does not get set back to 3.

     

    The other weird thing is that I have another set of fields after these, (all about activities instead of occupations) and they are set up EXACTLY the same way, but it works as expected.

  • jonathan
    Replied on January 30, 2015 at 4:03 AM

    Actually all 3 conditions are different. None of them are exactly the same.

    If you read them closely, you will understand that each does different thing.

    Calculation not triggering Image 1 Screenshot 60

     

    And I think the "None of the Above" option when checked will actually not work as intended... if I am not mistaken, the option was suppose to have result that none of the "occupation" were selected.

    BUT by just hiding the checked options, will not 'clear' any selection once selected already.

    See image below what I meant

    Calculation not triggering Image 2 Screenshot 71

     

    then

    Calculation not triggering Image 3 Screenshot 82

     

    #3

    Calculation not triggering Image 4 Screenshot 93

     

    I think a better method is to include the "None of the Above" option among the selections. Do not create a separate checkbox just for the "None of the above"

    And then use the Min/Max selected property of the Checkbox.

    Calculation not triggering Image 5 Screenshot 104

     

    You can put a Calculation Value of zero(0) for the None of the above option, while an occupation are equal to 1

    The conditional statement should be able to calculate properly then (all Sum of all 1.. and None of the above is always 0)

    Let me know if us know if you need further assistance on this.

    Thanks.

     

     

     

  • Deralict
    Replied on January 31, 2015 at 6:23 PM

    Hi,

     

    First of all, I am aware that checking "None of the Above" does not clear the other checkboxes, even though it hides them. This is why I need the condition:

     If checked, (equal to "None of the Above") INSERT 0 into "Occupations_result".

    Your suggestion won't work for me, because it would allow a user to provide an ambiguous response. That is, they could check both one or more occupations AND "none of the above".

    So if they check "none of the above" it has to either automatically UNCHECK all other occupations, or hide them and ignore the value of all checked occupations. Since I can't find a way to do the former with JotForm, I chose the latter. And as I said, it works with the "Activities" questions which are just below the Occupations questions. They are set up in exactly the same way, so I'd like to know why THEY work perfectly, but the Occupations questions do not work.

  • jonathan
    Replied on January 31, 2015 at 8:06 PM

    Thank you for the explanation and providing more details.

    I was able to understand further what you were trying to achieve.

    Can you please confirm that this is how the submission result look like

    Calculation not triggering Image 1 Screenshot 20

    in the test data on the screenshot, I selected 3 occupation and then 'None of the Above'.

    So are you saying that the conditional statement is not working because the '3' value should have been '0' instead because you have selected 'None of the above' option?

     

    Unfortunately there is no means within the Form Builder to uncheck/unselect the Checkbox items via another checkbox. The Checkbox is a multiple-option-select field.. unlike the Radio button which is a single-select-option toggle field.

    You can have such toggle/select option using checkboxes if you will use the form's source code and inject custom code function using javascript.

    I will wait for your updated response to know if I was able to correctly understand the issue  before proceeding.

    Thanks.

     

  • Deralict
    Replied on January 31, 2015 at 9:17 PM

    So are you saying that the conditional statement is not working because the '3' value should have been '0' instead because you have selected 'None of the above' option?

    Yes, exactly. This is how the "Activities" section works, and it has the same conditions.

     

    Unfortunately there is no means within the Form Builder to uncheck/unselect the Checkbox items via another checkbox

    Yes, I know. That would be a feature that would help me here, but even without it, the conditions feature in theory will allow me to accomplish what i need (and again, it works for the "Activities" section.

  • raul
    Replied on January 31, 2015 at 10:23 PM

    Could you please take a look at this form: http://form.jotformpro.com/form/50307977703964 and let us know if this is how the conditions should work?

    I've used an "is empty" condition instead of "not equal to" to use the calculated value when the "None of the above" field is unchecked.

    Calculation not triggering Image 1 Screenshot 20

    If this is what you want to accomplish, feel free to clone the form to your account if you want to.

    Let us know if you need further assistance.
    Thank you.

  • Deralict
    Replied on February 1, 2015 at 2:02 AM

    At first I thought it was exactly how I needed it to work, but after I tried it out I found it was doing something very strange that it wasn't doing originally:

    If I check one or more of the "occupations", then check "None of the above", the "Occupations_result" calculation field is set at zero (the condition is executing successfully!)

    If I then submit the form (after filling in all required fields), immediately after the Submit button is pressed but before the new page loads, the 0 in the "Occupations_result" field is replaced with a number (equal to how many occupations I've checked). And of course the incorrect thank-you page is then displayed.

    Here's a video clip that illustrates this.

    The same thing happens with the "Activities" fields.

    This didn't happen before.

    The other odd thing is I first changed the condition in my form to be an "is empty" condition like you suggested, but that had no effect. I ended up cloning your form instead.

  • abajan Jotform Support
    Replied on February 1, 2015 at 11:40 AM

    @Deralict

    Please test this demo. Would that sort of functionality be okay? If so, we next need to determine if you have adequate access to the Lifelong home page source because (besides some minor changes to your form in the form builder) this solution would require inserting a copy of your form's full source code, along with this script, into that page's source. To your knowledge, is that feasible?

  • abajan Jotform Support
    Replied on February 1, 2015 at 11:44 AM

    I should add that the calculation fields were made visible in the demo, only to show what results populate them as the form's fields are filled. They would be hidden in the live form, just as they are in your current version.

    Thanks

  • Deralict
    Replied on February 1, 2015 at 2:15 PM

    The way this form works is acceptable. My only concern is about embedding the source code--what happens when I need make changes to the form?

  • jonathan
    Replied on February 1, 2015 at 4:37 PM

    If understood correctly your concern on using the full source code embed of the form, is that you will need to re-embed the source code every time you make changes on the form.

    Yes, this is the process involved when using full source code embed.

    So it is best to finalize the form in the Form Builder as much as possible before taking its source code embed.

    Thanks.

     

  • Deralict
    Replied on February 1, 2015 at 4:55 PM

    OK...as long as I don't need to make any alterations to the source code that is embedded then that's no problem. I will try this and let you know how it works.

  • abajan Jotform Support
    Replied on February 1, 2015 at 5:10 PM

    Hi again,

    We're glad you're willing to give this a shot but don't do anything yet because as previously mentioned, besides hiding the calculation fields there are some changes which need to be made to the form before you place its source in your page. Also, for this to work, the script needs to be inserted after (at the bottom of) the form code, just like you'll see in the demo's source.

    I'll return a little later with the instructions but to address your concern, no changes would need to be made to the form code after it's embedded.

     


    Thanks

  • abajan Jotform Support
    Replied on February 1, 2015 at 9:08 PM

    Okay, here's what to do:

    1. Clone my jotform from the following link:

    http://form.jotformpro.com/form/50308828827967

    2. Copy its source code from the Embed Form Wizard, as explained in this guide, ignoring the part (pictured below) which comes just before the last paragraph of the guide:

    Calculation not triggering Image 1 Screenshot 30

    3. At this point your form code should be on your computer clipboard, ready to be pasted into the source of your home page. First delete the iFrame containing your old jotform and then paste the new code in its place

    4. Copy this code (the script) to your clipboard and paste it anywhere after the form code

    5. Wrap the script inserted in the previous step in script tags. If you examine the source of the demo you'll see that the script is indeed enclosed within such tags:

    Calculation not triggering Image 2 Screenshot 41

    6. Save the changes

    Your form should now work just like my demo.

    The above steps are less than originally intended because I realized that it would be simpler for you to just clone my form instead of making any changes to your current one.

    Should you encounter any difficulties, please don't hesitate to inform us in this thread.


    Cheers

  • Deralict
    Replied on February 3, 2015 at 3:35 PM

    OK, I've ALMOST got this working...the only problem I have is that my select boxes (dropdowns) are missing the dropdown indicator arrows on the right side of the select box.

    Compare this (embedded source code):

    Calculation not triggering Image 1 Screenshot 30

    With this (original, iFrame):

    Calculation not triggering Image 2 Screenshot 41

     

    My new form is in this page: http://www.lifesprung.com/staging/

  • raul
    Replied on February 3, 2015 at 4:45 PM

    I've moved your inquiry to a separate thread since it's related to a different issue.
    This will allow us to address it properly.

    You can find the new thread here: http://www.jotform.com/answers/509244

    We'll provide an answer as soon as we can.
    Thank you.