Background:
I have a datefield (which is, on document load, automaticly gets the current date).
You can edit this field and put in desired date if you want to.
The field name is: "Date1"
SCRIPT FOR "Date1":
var f = this.getField("Date1");
f.value = util.printd("yy/mm/dd", new Date());
---
I also have a field which you can put in a desired number of days.
The field name is: "Add_days"
----
And finally I have a datefield which add the input value of the "Add_days"-field and calculates it to a new date. The script is a "Custom calculation script".
The field name is: "Date2"
SCRIPT FOR "Date2":
var sDate1 = "Date1";
var sAdd_days = "Add_days";
var nAdd = this.getField(sAdd_days).value;
var sDateFmt = 'yy/mm/dd';
var sDate = this.getField(sName).value;
var oDate = util.scand(sDateFmt, sDate);
var nFullYear = oDate.getYear();
var nMonth = oDate.getMonth();
var nDate = oDate.getDate();
nNewDate = nAdd + nDate;
var oNewDate = new Date(nFullYear, nMonth, nNewDate);
var sNewDate = util.printd(sDateFmt, oNewDate);
event.value = sNewDate;
---
This is what I need help with:
I want the default value of "Date2", to be a slave to the value of "Date1"-field. So if the value of "Date1" is changed, the value of "Date2" also shall change.
I think its a very quick fix whith the "this.getField" script, but I cant get it to work.
Thanks for the help you guys!
- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com