Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How to auto fill a text box by selection an option from a dropdown menu

New Here ,
May 10, 2017 May 10, 2017

Hello, I'm new at this.

I am doing a PDF form and would like to fill a text box with the address of a vendor, once I selected the vendors name in a drop-down menu.  I am using Adobe Acrobat Pro DC, and having issue on what scrip to use and where to put it.

Any help would be appreciated.  Thanks in advance.

TOPICS
PDF forms
10.8K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
1 ACCEPTED SOLUTION
Adobe Employee ,
May 11, 2017 May 11, 2017

Hello,

You can follow below steps to put your javaScript :

Right click on your text-box.

Under Calculate tab->custom calculation script, put the below javaScript :

event.value = this.getField("<Your dropdown name>").value;

View solution in original post

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
May 11, 2017 May 11, 2017

Hello,

You can follow below steps to put your javaScript :

Right click on your text-box.

Under Calculate tab->custom calculation script, put the below javaScript :

event.value = this.getField("<Your dropdown name>").value;

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 19, 2017 Sep 19, 2017

How would i do the same thing but have a drop down box with several items (they all equal different values)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 19, 2017 Sep 19, 2017

The same code can be used with a drop-down field.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 21, 2021 Oct 21, 2021

Hello - I have a similar situation in a form, but struggling with figuring out a specific need. 

 

I want only one specific selection in a dropdown menu to populate into a textfield (a reminder, based on the selection). 

Text field name: "flag"

Drop down name: "type_vendor"

Drop down options:

  • Make a selection (default)
  • CE
    • Export value: "Remember to complete page two for CE vendors"
  • MER
  • Remittance
  • Support
  • Interpreter

 

I want the read-only text field blank, unless the "CE" option is selected from the drop down. 

 

This script works fine and I've used others that include multiple values from a list box, but the exclusivity part of only wanting one value or blank is throwing me off.. 

 

Any help or insight is appreciated! 

 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 21, 2021 Oct 21, 2021

also - the export value of "CE" should have been indented further, it is not one of the drop-down options! my bad.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 21, 2021 Oct 21, 2021

As custom calculation  script of text  field use this:

event.value = this.getField("type_vendor").valueAsString == "Remember to complete page two for CE vendors" ? this.getField("type_vendor").value : "";

EDIT: you want export value to show or CE?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 21, 2021 Oct 21, 2021

I want the export value to show only when that specific drop menu item is selected (CE). Blank for all other selections from the drop down. 
I must be mising something in the code?

event.value=this.getField("type_vendor")
.valueAsString == "Remember to complete page two for CE Vendors" ? this.getField("type_vendor").value:"";

 This code was working to populate each drop down selection's export value, but adding the specifics doesn't like me today... 

event.value=this.getField("type_vendor").value;
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 21, 2021 Oct 21, 2021

Script will populate "flag" field with export value from item 'CE' if 'CE' is selected from dropdown field and leave field "flag" blank if anything else is selected from dropdown field.

 

Can you explain what you want to achive with second script and where do you use it?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 22, 2021 Oct 22, 2021

The second code was where I started (sorry super backwards way of explaining). 

 

I figured it out - my export value of CE was not matching up with the code value! I phrased it slightly different. Thank you so much for your help! 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 04, 2021 Nov 04, 2021

I am working on a similar form.  I have a sales order form where I have dropdowns for different misc charges.  I would like it so that when my sales team selects an item from the dropdown it populates a price into a text box, and if nothing is selected, then I would like the text box to remain empty or populate 0.  

 

One of the dropdowns is "Title", and my textbox is "MiscAmount1".  I have tried to use the code above as my base and then tweaked it how I thought it would have to be and I either get the value that I want regardless of what is selected in the dropdown or I get nothing.  

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 11, 2022 Apr 11, 2022

This is confusing me to now end:  Below is my script.  I cannot find the error and it does not work in either the calculate tab or the run a java script tab.  Please assist.

var selectedUnit = this.getField("Unit").value;
if (selectedUnit=="1st Brigade (Engineer)") event.value = "AFRC-TVA-LWA";
else if (selectedUnit=="1st Battalion (Engineer) 80th Regiment") event.value = "AFRC-TVA-LWAA";
else event.value = "";

 

i HAVE MORE LINES TO ADD BUT i FIGURED IT WOULD BE EASIER TO EXPLAIN OR COMPREHEND WITH JUST A FEW LINES.

 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 11, 2022 Apr 11, 2022
LATEST

Is "Unit" dropdown or text field?

By the look of it, it should work fine.

If it's dropdown field make sure under field properties -> option tab check 'Commit selected value immediately'

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines