Skip to main content
Inspiring
July 10, 2017
Answered

I am having difficulties identifying empty empty fields to populate other field

  • July 10, 2017
  • 1 reply
  • 583 views

I am using JavaScript to Identify whether or not a field is filled or empty. Depending on the results, It will assign variable to fill in the rest of the form. I cant seem to figure out what I am doing wrong. I have tried .isNull , .rawvalue, etc..... Any help would be appreciated.

This is what I have so far.

// Automatically Populates the Team Technician to the rest of the document once the field is populated on the Mileage Sheet and sets variables to predefined values;

var team = this.getField("Team").value;
var lead1 = this.getField("Lead1").value;
var team1 = this.getField("Team1").value;


event.value = "";

if ((team.value !== null || team.value !== "")&&(lead1.value==null || lead1.value=="")){

               event.value=team;

}

else if ((team.value == null || team.value == "")&&(lead1.value!==null || lead1.value!=="")){

                event.value=lead1;


}

else if ((team.value == !null || team.value !== "")&&(lead1.value!==null || lead1.value!=="")){

                event.value=team;

}

This topic has been closed for replies.
Correct answer Duquette

Thank You for the suggestion Bernd, although it did not work, it did give me an idea. I assigned the variables:

var team = this.getField("Team").valueAsString;

It works as I hoped but have no idea why - can anyone explain this or point me in the direction where I can understand it better?

1 reply

Bernd Alheit
Community Expert
Community Expert
July 10, 2017

Look in the console for errors.

You don't use the values of the fields:

event.value = team;

You must use:

event.value = team.value;

DuquetteAuthorCorrect answer
Inspiring
July 10, 2017

Thank You for the suggestion Bernd, although it did not work, it did give me an idea. I assigned the variables:

var team = this.getField("Team").valueAsString;

It works as I hoped but have no idea why - can anyone explain this or point me in the direction where I can understand it better?

Bernd Alheit
Community Expert
Community Expert
July 10, 2017

You can find the description in the Acrobat JavaScript Reference.