Copy link to clipboard
Copied
I am having trouble with the switch line in a script I am trying to create. I am trying to get a text field to autofill with specific account number when the account type is selected from the dropdown button. I have tried using dropdownValue and eventValue as well putting a dot in between and still have the same syntax error each time.
Copy link to clipboard
Copied
You must only use straight quotes in your code, not curly ones.
Copy link to clipboard
Copied
An alternative approach is to assign the desired codes as the export values for each dropdown choice. For example, for "Admissions," set the export value to T22000-P170-82000-41
, and apply similar formatting for the remaining options.
Then, in the custom calculation script of the text field, use the following code:
event.value = this.getField("Dropdown2").value;
This will ensure the selected export value is automatically populated in the text field.
Copy link to clipboard
Copied
You must only use straight quotes in your code, not curly ones.
Copy link to clipboard
Copied
Do you mean quotation marks or parentheses? If quotation marks, not sure how mine sarted going from straight to angled. I will retype them all and see if that helps.
Copy link to clipboard
Copied
Quotation marks. It probably happened if you use an application like Word for writing the code, as it tends to do that automatically (unless you tell it not to). It's better to use a plain-text editor for your code. If you're on Windows, I highly recommend the free (and open-source) Notepad++.
Copy link to clipboard
Copied
That did fix the syntax error. I started typing the script in the form but then copied it to Word so I could see more of what I was typing & copy/pasting. Still trying to get the script to run in the text box. Trying Nesa's approach now. I am basically learning this as I go. No one in our IT department could help me with this.
Copy link to clipboard
Copied
Start by quitting and restarting Acrobat, it often becomes unstable after trying several different JavaScripts.
Edit: try67 answer is full of common sense.
Acrobate du PDF, InDesigner et Photoshoptographe
Copy link to clipboard
Copied
An alternative approach is to assign the desired codes as the export values for each dropdown choice. For example, for "Admissions," set the export value to T22000-P170-82000-41
, and apply similar formatting for the remaining options.
Then, in the custom calculation script of the text field, use the following code:
event.value = this.getField("Dropdown2").value;
This will ensure the selected export value is automatically populated in the text field.
Copy link to clipboard
Copied
This worked! Thank you so much Nesa and try67 for all your help! I greatly appreciate it!

