Skip to main content
ls_rbls
Community Expert
Community Expert
June 11, 2020
Answered

Can I use event.change and event.changEx with date pickers?

  • June 11, 2020
  • 1 reply
  • 2021 views

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.

This topic has been closed for replies.
Correct answer try67

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

}

1 reply

try67
Community Expert
Community Expert
June 11, 2020

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.

ls_rbls
Community Expert
ls_rblsCommunity ExpertAuthor
Community Expert
June 11, 2020

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?

 

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
June 11, 2020

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

}