"Simplified notation" value calculation: how?

Forum for the PDF-XChange Editor - Free and Licensed Versions

Moderators: TrackerSupp-Daniel, Tracker Support, Paul - Tracker Supp, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Ivan - Tracker Software, Tracker Supp-Stefan

Post Reply
claude vidal
User
Posts: 138
Joined: Wed Mar 09, 2016 12:47 am

"Simplified notation" value calculation: how?

Post by claude vidal »

Let's say a form with two date fields, Date1 and Date2. I'm trying to set Date2 to "Date1 + 2" by specifying a value calculation of "Simplified notation": Date1 + 2. Does not seem to work. What am I missing?

Update: here is what I get for Date2 and I only get this after I select any date from the Date2 calendar
image.png
image.png (7.61 KiB) Viewed 1036 times
User avatar
TrackerSupp-Daniel
Site Admin
Posts: 8548
Joined: Wed Jan 03, 2018 6:52 pm

Re: "Simplified notation" value calculation: how?

Post by TrackerSupp-Daniel »

Hello Claude,

This will not be possible with simplified notation, as a custom script is required.
I have included one here:

Code: Select all

//Date format is important, make sure that ["dd mmmm yyyy"] matches your desired format
//"Date1" is the field name for the field you are selecting manually
var date= util.scand("dd mmmm yyyy", this.getField("Date1").value);
//+2 in this line is the number of days to add to the original field
//IE 2 months would be +60
date.setDate(date.getDate()+2)
if (this.getField("Date1").value!="")
{
//Same here, ensure that date format matches
event.value=util.printd("dd mmmm yyyy",date)
}
//this keeps the field blank until an input exists in the first field
else
{event.value=""}
Simply create a text field (you can lock it if you want to prevent users from editing it manually) then change the value calculation to "custom action" and choose "Run a javascript" then paste the code above into the window.

This script assumes that the first date field is named "Date1" so you may need to modify the script for it to work with your existing document.
Dan McIntyre - Support Technician
Tracker Software Products (Canada) LTD

+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com
claude vidal
User
Posts: 138
Joined: Wed Mar 09, 2016 12:47 am

Re: "Simplified notation" value calculation: how?

Post by claude vidal »

Daniel,

Thanks, did the job.
User avatar
TrackerSupp-Daniel
Site Admin
Posts: 8548
Joined: Wed Jan 03, 2018 6:52 pm

Re: "Simplified notation" value calculation: how?

Post by TrackerSupp-Daniel »

:D
Dan McIntyre - Support Technician
Tracker Software Products (Canada) LTD

+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com
Post Reply