Calculating age field populated before date entered

  • DreamCalisthenics
    Asked on August 1, 2015 at 8:05 PM

    Hi,

    I'm calculating age and its working well. When I preview the form though it populates the field with a value (115) before the date of birth is populated. Could you tell me how I can make the field stay blank. The wait for input in advanced options doesnt work without breaking the calculation.

    Cheers

    Ben

    Jotform Thread 625861 Screenshot
  • David JotForm Support Manager
    Replied on August 1, 2015 at 9:49 PM

    That's because the math functions do not read the "wait for input" option, a workaround on this is to insert those values(Today's Date, and 365.25) based on a condition IF Date of Birth field is filled:

    1) We add two calculation widgets:

    Calculating age field populated before date entered Image 1 Screenshot 50

    2) We create two conditions to fill them with the corresponding values if Date of Birth field is filled:

    Calculating age field populated before date entered Image 2 Screenshot 61

    3) We replace the values for those fields into the Form Calculation widget that displays the age?

    Calculating age field populated before date entered Image 3 Screenshot 72

    This is how it works know:

    Calculating age field populated before date entered Image 4 Screenshot 83

    Here is my cloned version: http://form.jotformpro.com/form/52128308346958?

    You may clone it if you want to: http://www.jotform.com/help/42-How-to-Clone-an-Existing-Form-from-a-URL

    Let us know if you need more help, we will be glad to assist you.

  • DreamCalisthenics
    Replied on August 1, 2015 at 11:03 PM

    Thanks for the answer! :-) The system is a little clumsy that you have to add so many hidden fields to make it work. I'm going to do it the easy way and simply hide the age field until DOB is filled.

    I've also found that hidden fields cant be grouped after the submit button. I was trying to do this to deal with the tidiness of the form layout for global hidden variables but it broke the form.

    Thanks again for your help.

    Ben

  • Mike_G JotForm Support
    Replied on August 2, 2015 at 3:19 AM

    You might want to consider using a regular TextBox for Age field instead of using a Form Calculation Widget. 

    Calculating age field populated before date entered Image 1 Screenshot 50

    And then, create your condition using the Condition Wizard: 

    Calculating age field populated before date entered Image 2 Screenshot 61

    Calculating age field populated before date entered Image 3 Screenshot 72

    Here, you would only be needing one hidden field(Current Date). And, part of the Condition is that it will wait for the Date Field to be filled before the computation starts and place an output to the Age field.

    You might want to check the form I've used in my example: http://form.jotformpro.com/form/52131025777956

    I've also found that hidden fields cant be grouped after the submit button.

    I'm not sure what you mean hear clearly, but I have tried placing the hidden field after the Submit button and the condition still works:

    Calculating age field populated before date entered Image 4 Screenshot 83

    I hope this helps. Let us know if you need any further assistance. Thank you. 

  • DreamCalisthenics
    Replied on August 2, 2015 at 4:29 AM

    Thanks Mike_G for your solution it works except I needed to use a number field to get the right conditional logic for the subsequent logic. (Age greater than/Age less than etc)

    I'll go back and check the hidden fields being published after the submit button problem.

    Thanks again!

  • Mike_G JotForm Support
    Replied on August 2, 2015 at 5:40 AM

    You can, also, use the Number field for the Age field instead of a regular TextBox field if you will be needing it for a condition that requires you to know if the value of the Age field is Greater Than or Less than another value.

    Calculating age field populated before date entered Image 1 Screenshot 30

    Calculating age field populated before date entered Image 2 Screenshot 41

    Here's the form I've used this time: http://form.jotformpro.com/form/52132443202944

    I hope this helps. 

    As for the hidden fields added after the submit button, please do update us of your findings and let us know if you need any further assistance. Thank you.

  • DreamCalisthenics
    Replied on August 3, 2015 at 3:26 AM

    That's what I did :-) I'd already worked that out.

    Thanks for your help.