Copy link to clipboard
Copied
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;
}
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?
Copy link to clipboard
Copied
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;
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
You can find the description in the Acrobat JavaScript Reference.
Copy link to clipboard
Copied
Thank You