Planet PDF Forum Planet PDF Forum
  New Posts New Posts RSS Feed - Auto populating Date field -Feb. is an issue
  FAQ FAQ  Forum Search   Register Register  Login Login


Hi, welcome to the Foxit Planet PDF Forum. If you have PDF or Adobe Acrobat questions then the right place to ask them is here, in this forum.

Auto populating Date field -Feb. is an issue

 Post Reply Post Reply
Author
Brianwh View Drop Down
New Member
New Member


Joined: 10 Feb 2017
Points: 5
Post Options Post Options   Quote Brianwh Quote  Post ReplyReply Direct Link To This Post Topic: Auto populating Date field -Feb. is an issue
    Posted: 13 Feb 2017 at 6:03pm
Thought I would repost here.
 
Hello All,

I have read a number of posts on several sites. Additionally have noted a number of knowledgeable folks supporting all the of the newb questions. I have visited some resource sites like adobe. and various forums like this one.
However I am still not able to glean the solution for the correct java script that will address correctly auto populating the  Month of February if 1.29 thru 1.31 is selected in the initial date field.
all other dating works correctly
Form has 3 date fields, I am trying to provide script that will allow my users to populate the first field and the 2nd and 3rd field will be dated 1 month later , naturally Feb. is an exception
the main script I have used to this point is
 // get value of field to update - field name is Text5
var sDate = this.getField('Text5').value;
// convert to date time object
// the fields format is mm/dd/yyyy
var oDate = util.scand('mm/dd/yyyy', sDate);
// get the parts of the date
var fFullYear = oDate.getFullYear(); // 4 digit year
var fMonth = oDate.getMonth(); // zero based month
var fDate = oDate.getDate(); // date of month
// increment the month
fMonth++;
// create new date time object
var oNewDate = new Date(fFullYear, fMonth, fDate);
// set field value - field has no format
// formatting is applied by the printd method
event.value = util.printd('mm/dd/yyyy', oNewDate);
I have tried a couple others that I could share if needed, however the result of those scripts is the same...I can share the other variations of java scripts used in further posts.
 
Any assistance in creating the additional scripting needed would be Greatly appreciated.
Ps I have tried tweaking this with formula for adding or subtracting days but alas not doing it correctly.
Again Thank you in advance
Brian
Back to Top
Sponsored Links


Back to Top
Merlin View Drop Down
New Member
New Member
Avatar

Joined: 03 Jun 2012
Location: 43.95 N / 4.82
Points: 32
Post Options Post Options   Quote Merlin Quote  Post ReplyReply Direct Link To This Post Posted: 14 Feb 2017 at 11:50am
Hi.

You dreamed of, Joel made it for you!
dateExtended Library for Adobe Acrobat: http://practicalpdf.com/the-practicalpdf-date-library-for-adobe-acrobat/

Back to Top
Brianwh View Drop Down
New Member
New Member


Joined: 10 Feb 2017
Points: 5
Post Options Post Options   Quote Brianwh Quote  Post ReplyReply Direct Link To This Post Posted: 14 Feb 2017 at 8:34pm

Hello Merlin,

 
thank you for the great link.
It would seem that Joel has created nice piece of scripting.
Not sure how I would apply this to my document! Any suggestions
Back to Top
Merlin View Drop Down
New Member
New Member
Avatar

Joined: 03 Jun 2012
Location: 43.95 N / 4.82
Points: 32
Post Options Post Options   Quote Merlin Quote  Post ReplyReply Direct Link To This Post Posted: 14 Feb 2017 at 10:23pm
I not sure why february should more difficult to manage than any other 30 days month.
Add 30 days instead of one month...
;-)


Edited by Merlin - 14 Feb 2017 at 10:24pm
Back to Top
gkaiseril View Drop Down
Senior Member
Senior Member


Joined: 15 Jul 2011
Location: USA
Points: 4060
Post Options Post Options   Quote gkaiseril Quote  Post ReplyReply Direct Link To This Post Posted: 16 Feb 2017 at 6:52pm
February never has 30 or 31 dayS. Do you need to add one month or 30 days?

Only 4 months have 30 days.
Back to Top
Brianwh View Drop Down
New Member
New Member


Joined: 10 Feb 2017
Points: 5
Post Options Post Options   Quote Brianwh Quote  Post ReplyReply Direct Link To This Post Posted: 16 Feb 2017 at 7:08pm
Gkaiseril thank you for weighing in. ( I have noted your input in other forums as well)
yes I understand that Feb. is different than any other month, even in a leap year.
and that some months have 30 days and others have 31 days.
I have set a form to populate the date placed in field 1 to 2 other fields with 30 days incremented.
naturally if the initial field has 31 days and the following month on has 30
or if Jan 30 is selected then the following date will not be Feb. (xx)
this is the issue I am trying to address, how to write the script needed to compensate for the varying dates when an initial date is place in field 1 and auto-populating the following date fields with a standard 30 day spread.
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.09
Copyright ©2001-2017 Web Wiz Ltd.

This page was generated in 0.018 seconds.