Copy link to clipboard
Copied
Hi there,
I need help creating a JavaScript calculation that will pull in 120 consecutive dates based on the initial date. The code I am using only pulls the next date. Any assistance would be greatly appreciated!
var date = util.scand("mm/dd/yyyy", event.value);
if(event.value == "")
this.getField("Date1").value = "";
else {
date.setDate(date.getDate() +1);
this.getField("Date2").value = util.printd("mm/dd/yyyy", date);}
Thank you,
Angela
Copy link to clipboard
Copied
Enter the following custom validation script in the Date1 field:
if(event.value)
{
var date = util.scand("mm/dd/yyyy", event.value);
for(var i=2;i<=120;i++)
{
date.setDate(date.getDate() +1);
this.getField("Date"+i).value = util.printd("mm/dd/yyyy", date);
}
}
Copy link to clipboard
Copied
It works for me. Did you copy and paste the code a custom validation script in Date1? Did you also remove your calculation script?
Copy link to clipboard
Copied
Enter the following custom validation script in the Date1 field:
if(event.value)
{
var date = util.scand("mm/dd/yyyy", event.value);
for(var i=2;i<=120;i++)
{
date.setDate(date.getDate() +1);
this.getField("Date"+i).value = util.printd("mm/dd/yyyy", date);
}
}
Copy link to clipboard
Copied
Thank you for your help! The code entered date1 and date2 consecutively, but date3 through date120 populated the same date, 5/9/2025?
Copy link to clipboard
Copied
It works for me. Did you copy and paste the code a custom validation script in Date1? Did you also remove your calculation script?
Copy link to clipboard
Copied
Aha! I thought I deleted the custom validation script, but alas, I did not.
Thanks for your help!