Copy link to clipboard
Copied
I am looking for a script to auto complete a text field when a specific number is imputted into another field, so that user filling out form does not have to reference another document to find the corresponding number, aim is to reduce human error input by making the document do the hard work.
i.e. text fields are 'Origination - Unwind Direction 1' (this is field 1) & Origination - Unwind Direction 2' (this is field 2)
If I were to enter '1' in to Field 1, I want Field 2 to automatically show '2', or if i were to enter '3' into Field 1, I want Field 2 to show '4'. Input will continue roughly on this basis.
Aim is to lock Origination - Unwind Direction 2 (Field 2) from user filling out form so that errors cannot occur, thansk for any help
From example you posted, you can use script in first field under validation:
if(event.value == 1)this.getField("Origination - Unwind Direction 2").value = 2;
else if(event.value == 3)this.getField("Origination - Unwind Direction 2").value = 4;
from here you can continue adding 'else if' statements and if you wish, statement to empty field 2 if field 1 is empty.
In your example field 2 is always 1 more then field 1, if that will be case you can use this script in same place instead of script above:
Copy link to clipboard
Copied
From example you posted, you can use script in first field under validation:
if(event.value == 1)this.getField("Origination - Unwind Direction 2").value = 2;
else if(event.value == 3)this.getField("Origination - Unwind Direction 2").value = 4;
from here you can continue adding 'else if' statements and if you wish, statement to empty field 2 if field 1 is empty.
In your example field 2 is always 1 more then field 1, if that will be case you can use this script in same place instead of script above:
var x = Number(event.value);
this.getField("Origination - Unwind Direction 2").value = event.value != "" ? x+1 : "";
Copy link to clipboard
Copied
Thanks, worked like a dream
Copy link to clipboard
Copied
Hi Craiga
Hope you are doing well and sorry for the trouble. As described you want a script to auto complete a text field when a specific number is imported into another field, so that user filling out form does not have to reference another document to find the corresponding number.
For information about developing JavaScript please check the help page https://acrobatusers.com/tutorials/javascript_console/
Hope this information will help
Regards
Amal