Skip to main content
Known Participant
May 22, 2025
Question

Name and Pin if true auto populate another field with a number

  • May 22, 2025
  • 1 reply
  • 1527 views

I am a novice to javascript and I am using Adobe Pro. I am trying to get a name and pin combination and if true have a different field auito populate a prior approval number of 8 digits. I have tried numerous suggetions from the community but I have not had success. I basically have no code to create this. Thank you for your help.

1 reply

try67
Community Expert
Community Expert
May 22, 2025

You need to provide some more info. By "pin" do you mean password, as in a login? If so, where is the login information stored? In your code? Are you aware that that code can be viewed by anyone who has Acrobat (or other similar tools), and is therefore not secured at all?

Also, what "approval number" do you want to display? A fixed one? A random one? Something else?

Please be more specific.

brantpro1Author
Known Participant
May 22, 2025

Great questions. I am not to worried about overall security. Then pin is a four digit pin. I can store in a excel file or in code, would need to know ho to do excel file. The approval number is a fixed assigned number to each person and needs to be in a text field in the form. Thank you

brantpro1Author
Known Participant
May 23, 2025

It needs to be in a button. If you want it to execute automatically then move it to the Calculation event of "Approval Number", remove the alert and change all instances of:

this.getField("Approval Number").value = ...

To:

event.value = ...


Here is the correted code. I put the Pin number and then the name and hit enter and Approval Number does not populate. Any help is great. Thank you.

function autoFill() {
var name = this.getField("Name").value;
var pin = this.getField("Pin").value;
if (name === "Yookyung Kim" && pin === "1492") {
event.value = "12481570";
} else if (name === "Madison St.John" && pin === "8107") {
event.value = "12453397";
} else {
event.value = "";
}
}