Expand my Community achievements bar.

SOLVED

HELP! Script to populate a text field based off of whats picked in a dropdown on a previous page?

Avatar

Level 1

Alright hopefully i can explain this good enough.

I have a dropdown box that has two different options to pick from.  For example:

Dropdown1 has:  Option A

                         Option B

On the other page I have two text fields.  TextField1 just shows whatever is picked from the Dropdown1 (Option A or Option B).  TextField2 needs to do the following:  If Option A is picked i just need the field to stay blank.  If Option B is picked i need it to populate specific text.

I thought i figured out a way to do this but it seems that since it is on a different page the script will not fire.

Any help is much appreciated!!!!!!

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

You can upload it onto Acrobat.com and then Publish the form. Once you have published you can copy the link and share it here.

In my example I was using the name of the first object "TextField1" as an example. If your first object is named differently, then you will need to change the script accordingly.

There is an example on how to reference objects here: http://assure.ly/kUP02y.

Niall

View solution in original post

4 Replies

Avatar

Level 10

Hi,

With the first issue: having the dropdown and the first textfield displaying the same value, the easy solution is to use Global Binding.

  1. Make sure that the dropdown and the first textfield have the same name in the hierarchy.
  2. The select one of them and in the Object > Binding palette, set the binding to Global.
  3. In the dropdown go to the Object > Binding palette and make sure that "Specify values" is NOT ticked.
  4. It is probably a good idea to set the textfield to read only, in the Object > Value palette. This would prevent the user overwriting the value set by the dropdown.

No script required. Whatever is in the dropdpwn will appear in the textfield.

The second issue needs a small script in the calculate event of the second textfield. This looks at the value in the first textfield (TextField1) and sets its own value. This is JavaScript:

if (TextField1.rawValue == "Option B")

{

     this.rawValue = "Specific text";

}

else

{

     this.rawValue = null;

}

There are some examples here: http://assure.ly/jtTkdO, http://assure.ly/fYCuQ2.

Hope that helps,

Niall

Avatar

Level 1

Thank you Niall very much for you quick reply!!! I tried a clean test for what you supplied.  The first part is working perfectly but for some reason it is not pulling in the text in TextField2 on page 2 when Option 2 is picked.  I have a sample of what im talking about for you to review but cant seem to find out how to upload the PDF to this discussion...I can email it to your if you prefer?

Avatar

Correct answer by
Level 10

Hi,

You can upload it onto Acrobat.com and then Publish the form. Once you have published you can copy the link and share it here.

In my example I was using the name of the first object "TextField1" as an example. If your first object is named differently, then you will need to change the script accordingly.

There is an example on how to reference objects here: http://assure.ly/kUP02y.

Niall

Avatar

Level 1

Thank you so much for your help.  Right after i posted the last reply i discovered my problem.  Works like a charm!!