Copy link to clipboard
Copied
I have a date field in my PDF that is using a custom calculated script to get the date value from another date field.
I want to be able to have the option to manually change the date in that field using its own date picker.
The problem I have is that my current script partially works but it looses the focus and reverts to the custom calculated value when I continue to work with other fields.
This is the script that I 'm using:
//event.target is the current date field I want to execute this script
var a = event.target;
if (getField("myOtherDateField") !="") {
var s = a.value = this.getField("myOtherDateField").value;
var d = util.scand("mmmm, d yyyy", s);
d.setDate(d.getDate()+0);
event.value = util.printd("mmmm, d yyyy", d);
} else {
if (a.value = event.changeEx) {
a.value = event.change;
}
}
In the code above I know there is a lot wrong. I understand that event.change and changeEx is normally used with dropdown menus and text fields.
Is there a way to achieve this with date pickers?
It seems like it can work out, but like I indicated it looses the focus and reverts to the calculated value if I click and hit enter on any other field.
I would like to give my users the ability to manually change the date in that field after it has been populated with the value of the other date field.
Thank you in advance.
I would do it differently. Chang the code to only update the field's value automatically if the source of the event (event.source) is the other date field. Otherwise, it will not change it and the user could update the value manually.
The SDK doesn't deal with scripting techniques, it just provides the basic documentation of the various objects.
You can do it like this:
if (event.souce && event.source.name=="myOtherDateField") {
// place calculation code here
}
Copy link to clipboard
Copied
I would do it differently. Chang the code to only update the field's value automatically if the source of the event (event.source) is the other date field. Otherwise, it will not change it and the user could update the value manually.
Copy link to clipboard
Copied
Thanks for your usual quick replies.
I am using as reference the SDK documentation.
There is little to nothing mentioned in the references I'm using about how to implement event.source to update another field automatically.
Do I have to declare a function, or set a variable with function using something like an updateto method?
Copy link to clipboard
Copied
The SDK doesn't deal with scripting techniques, it just provides the basic documentation of the various objects.
You can do it like this:
if (event.souce && event.source.name=="myOtherDateField") {
// place calculation code here
}
Copy link to clipboard
Copied
Great! That did it.
This is how it looks:
if (event.source && event.source.name =="myOtherDateField") {
var s = this.getField("myOtherDateField").value;
var d = util.scand("mmmm, d yyyy", s);
d.setDate(d.getDate());
event.value = util.printd("mmmm, d yyyy", d);
}
I appreciate your continued support.