Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Auto-Updatable Date Field

Status
Not open for further replies.

PCHomepage

Programmer
Feb 24, 2009
609
US
On an Acrobat form, I have a date field that I would like to have show the current date before the user begins filling the form. Maybe it can simply look to see if they've entered their name and that would be enough to make in lock into whatever the current date is.

For testing purposes I have it set to use the time rather than the date and date field is called "Today" while the name field is "01":

Code:
var f = this.getField("Today");
if this.getField("01"){
f.value = util.printd("HH:MM:ss", new Date());
}
 
I have modified the conditional a bit and have eliminated the errors but it's still not working properly. Even without any conditional at all, the field does not get updated. It changes only when I modify and re-save the JavaScript but not when I close and re-open the form. Any ideas and to make it more dynamic? This is what I have so far:

Code:
var f1 = this.getField("01");
var f2 = this.getField("Today");

if (f1.value == "") {
f2.value = util.printd("HH:MM:ss", new Date());
} else {
f2.value = "";
}
 
Okay, I found the problem and that was tha the script needed to be in the Full Name field rather tha being in the Today field and I removed the else from the conditional. Now it works as it should:

Code:
var f1 = this.getField("01");
var f2 = this.getField("Today");

if (f1.value == "") {
f2.value = util.printd("HH:MM:ss", new Date());
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top