Question : Can Javascript in Acrobat get the next month and enter into multiple form fields?

Good, whatever time of day it is,

I have a button in acrobat javascript that will assign the current month in the "mm" format into multiple form fields, I also need a button that will assign whatever the next month is to those fields.
The buttons are a choice of when to start, this month or next month.

I have attached my code for my single, "add current month button", which is probably the wrong way, but it works.  Everything I have read, I can't quite get to work with my simple need.  Because it is already displaying in the "mm" format, 01, 05, etc. I really just need it to add 1 to 01-11 and an if 12 then minus 11 bit of code.

Am I missing something really simple here?
thanks for your time.
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
var fld =
this.getField("StartMonthA");
 
fld.value =
util.printd("mm",new Date());
 
var fld =
this.getField("StartMonthB");
 
fld.value =
util.printd("mm",new Date());
 
var fld =
this.getField("StartMonthC");
 
fld.value =
util.printd("mm",new Date());
Open in New Window Select All

Answer : Can Javascript in Acrobat get the next month and enter into multiple form fields?

Thanks for the pointer.

I was getting stuck using the util.printd, I think that is just for dates.
Using the 1st link you posted and finding out from another post you made on how to just plain write to a form field, I was able to cobble together the attached code.

The +2 offset is required cause months go 00-11.
The 1st if statement lets me rollover from Dec. to Jan.
The 2nd if statement lets me have always a 2 digit month.

I feel like I should be able to write something like:
this.getField("StartMonthA", "StartMonthB").value = (month);

But I can't figure it out.

Thanks for you help.
1:
2:
3:
4:
5:
6:
7:
8:
9:
var today_date= new Date()
var month=today_date.getMonth()+2
if (month   > 11) { month = month - 12;      }
if (month   < 10) { month = "0" + month;      }
 
 
this.getField("StartMonthA").value = (month);
this.getField("StartMonthB").value = (month);
this.getField("StartMonthC").value = (month);
Open in New Window Select All
Random Solutions  
 
programming4us programming4us