Skip to main content
January 25, 2017
Question

JavaScript Question

  • January 25, 2017
  • 1 reply
  • 241 views

Hi,

I am trying to make a PDF - I want one section to autofill using a java script.

I have 4 names in a drop down field called: "Site Contact"

I would like another field to auto populate a phone number - for instance:

If "Joe" then "1-800-555-5555"

And an option that if there is no name selected then it is blank.

Can i do this?

Thanks,

[ Mod: Changed subject form "Java" to "JavaScript" Question - this has nothing to do with Java ]

This topic has been closed for replies.

1 reply

try67
Community Expert
Community Expert
January 25, 2017

As the custom calculation script of the phone field you can use something like this:

var name = this.getField("Site Contact").valueAsString;

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

else if (name=="Joe") event.value = "1-800-555-5555";

else if (name=="Mary") event.value = "1-800-555-5556"; // etc.