Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Field to display today's date (mm/dd/yyyy) +15 days.

Community Beginner ,
May 31, 2016 May 31, 2016

Good morning,

I thought i nailed this one but it's doing something strange. My script is wrong but i'm learning as I go...

I added a script that auto-populates today's date and adds + 15 days to the date. When I Preview the field, it works find. However when I tab over to another field and add a value (doesn't matter what the other fields are), the initial date field keeps adding more days. Example, if the next two fields were simple check boxes (not tied to the date field in any way) and I were to check the boxes back and forth, the date field keeps jumping to a higher date.

var myDate = util.scand("mm/dd/yyyy", this.getField("GLOBAL__POSTING_DATE_15").valueAsString) ;

myDate.setDate(myDate.getDate() + 15);

event.value = util.printd("mm/dd/yyyy", myDate)

Is there a way to keep the date displayed and not get updated unless the user manually changes the date and only then does it add 15 days to that new date?

Thanks,

Edgar Arreguin

TOPICS
Acrobat SDK and JavaScript
942
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 31, 2016 May 31, 2016

Where did you place this code?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 31, 2016 May 31, 2016

Custom calculation script in the Calculate tab.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 31, 2016 May 31, 2016

Maybe a hidden field would prevent this?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 31, 2016 May 31, 2016

In what field did you add this script?

Is there any script that is updating the "GLOBAL__POSTING_DATE_15"?

Do you have a field with today's date?

If so, I would have places the code in the "on blur" action and use the value of today's date field for the base date for adjustment. That way the "GLOBAL__POSTING_DATE_15" would only be updated as the today's date field is changed.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 31, 2016 May 31, 2016

I have a single field where I inserted the script. Field name titled "GLOBAL__POSTING_DATE_15". From the script, the date auto populates mm/dd/yyy and adds +15 days.

Bare with me as i'm still learning. I'm not familiar with "on blur"action but assuming you meant adding it to the actions tab as opposed to the Calculate tab, I can give that a shot.

-Ed

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 31, 2016 May 31, 2016

You can't do it like that. You've created a circular calculation. Each time you take the value of the field and add 15 days to it... You need to use some other event to trigger the calculation, or use the current date in your script, instead of the value that's already in the field.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 31, 2016 May 31, 2016

I jumped the gun. I was seeing results based on a value (date) already populated. When i clear text, nothing happens,.

In the actions tab, after selecting blur trigger, what action do i select? JavaScript not working.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 31, 2016 May 31, 2016
LATEST

Thanks everyone. I was able to make it work using George's suggestion. See link..

Add x days to x date

Only difference is that the original date (auto imported by our UI interface) is hidden.

Defaulted the value of 15 to the second field and made it hidden as well.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines