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.
Calculating age field populated before date enteredAsked by bmanfield on August 01, 2015 at 08:05 PM
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.
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:
2) We create two conditions to fill them with the corresponding values if Date of Birth field is filled:
3) We replace the values for those fields into the Form Calculation widget that displays the age?
This is how it works know:
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.
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.
You might want to consider using a regular TextBox for Age field instead of using a Form Calculation Widget.
And then, create your condition using the Condition Wizard:
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:
I hope this helps. Let us know if you need any further assistance. Thank you.
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.
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.
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.
That's what I did :-) I'd already worked that out.
Thanks for your help.