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

New Here ,
May 10, 2017 May 10, 2017

Copy link to clipboard

Copied

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

Views

3.6K

Likes

Translate

Translate

Report

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

correct answers 1 Correct answer

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;

Likes

Translate

Translate
Adobe Employee ,
May 11, 2017 May 11, 2017

Copy link to clipboard

Copied

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;

Likes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

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 Community Professional ,
Sep 19, 2017 Sep 19, 2017

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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! 

 

 

Likes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

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 Community Professional ,
Oct 21, 2021 Oct 21, 2021

Copy link to clipboard

Copied

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?

Likes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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;

Likes

Translate

Translate

Report

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 Community Professional ,
Oct 21, 2021 Oct 21, 2021

Copy link to clipboard

Copied

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?

Likes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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! 

 

Likes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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.  

Likes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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.

 

 

Likes

Translate

Translate

Report

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 Community Professional ,
Apr 11, 2022 Apr 11, 2022

Copy link to clipboard

Copied

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'

Likes

Translate

Translate

Report

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