Skip to main content
Participating Frequently
August 24, 2023
Answered

Adding to a selcted date with java

  • August 24, 2023
  • 1 reply
  • 1148 views

Hi,

 

I found this code in a previous old post. Can anyone help as this does not seem to be working properly:  Im using this code :  I need it to add days to a selected date in field "date1"

 

 

var s1 = this.getField("Date1").valueAsString;

if (s1="") event.value = "";

else {

var d1 = util.scand("dddd dd/mm/yyyy", s1);

d1.setDate(d1.getDate()+1);

event.value = util.printd("dddd dd/mm/yyyy", d1);

}

 

This is not pulling from field Date1 though, it is using the current day as input.  Can anyone see what ive done wrong?

 

 

This topic has been closed for replies.
Correct answer Nesa Nurani

Hi,

 

Thats exactly what i have typed, ive even copy and pasted yours to make sure.  the field has gone blank and the dubgger states

 

TypeError: d1 is null
9:Field:Calculate

 

 


Can you share your file?

Make sure the date in "Date1" is in correct format.

1 reply

Bernd Alheit
Community Expert
Community Expert
August 24, 2023

Change

 if (s1="")

to

 if (s1=="")

 

Info: Acrobat doesn't use Java

tboden85Author
Participating Frequently
August 24, 2023

Hi,


TypeError: d1 is null
9:Field:Calculate

 

Does this make sense to you?