Jump to content

calculate age


Recommended Posts

You can insert the following in the Footer to calculated the age, and assign the value to the "Age" field after submitting:

<SCRIPT LANGUAGE="JavaScript">
function ageCalculate()
{
//get current date
var stamp = new Date(); 

//get Birthday. change "InsertRecordBirthday" if the fieldname is different
var insertDate = document.getElementById('InsertRecordBirthday').value;
var birth = new Date(insertDate);

//calculation
difference = stamp - birth;
age = Math.floor(difference / (1000 * 60 * 60 * 24 * 365.25));

//assign it to Age field 
document.getElementById('InsertRecordAge').value = age;
}

document.getElementById("caspioform").onsubmit=ageCalculate;
</SCRIPT>

Link to comment
Share on other sites

  • 2 weeks later...
  • 5 years later...

Hi,

 

The Calculated Value form element generates dynamic calculations that automatically update as users interact with your form is now available in the current platform of Caspio. You can calculate the age of a person automatically without submitting the form and without custom programming.

You can construct the calculation using functions, logic, constants, values from other fields and SQL expressions. 

You can refer to these links: https://howto.caspio.com/datapages/datapage-components/calculated-values/

                                                                https://howto.caspio.com/function-reference/

 

Regards,

kristina

 

Link to comment
Share on other sites

  • 6 months later...
  • 3 years later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...