Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Add script to a drop-down list to populate another field depending on the user's selection

Avatar

Level 1

I know pretty much nothing about writing script but I am trying to create two drop down boxes that are dependant on one another.  I am looking for a script that I can basically cut and paste into my form without using any data source.

I currently have a script set up in a subform.  I am looking for directions from start to finish in laymens terms.

The two boxes are basically catagories and subcatagories.  There are 9 catagories and anywhere between 3 and 7 subcatagories.

Please help!!

Thank you in advance!

0 Replies

Avatar

Level 1

The sample given sort of worked, one box is working but the second box is not working.  When I open it i

n Adobe Prof and run the debugger I get the following error, that I cannot figure out,

SyntaxError: invalid label

2: XFA: PProjectWriteUp[0].ProjectWriteUp[0].subform1[0].Categ4ry[0]: exit

can anyone tell me what this means and how to fix it.  I can't find the problem.

Avatar

Level 1

Hi, I first want to make it clear that I do not know how to code. I can, however, change values in code to match my needs. Take this pdf you attached for instance. I have a very similar need. I will have many dropdowns on pdf specsheets for custom light fixtures. When the "Size" is selected, the only the available wattages for THAT size would be in the "wattage" dropdown. I opened the file you attached, but I can not for the life of me find the data I need to change to fit my needs. I also need to learn how to repeat this on hundreds of specsheets.

If you can help me, it would be great.

Avatar

Level 2

Are you using Adobe LiveCycle Designer? If so when you have the form open in designer, click on the dropdowns you will see in the code behind that dropdown where it calls a variable which is called myScriptObject. Behind the drop-down list called "teams" it calls this script.

Here is what is in the scriptobject:

var epl = "Chelsea,Manchester United,Arsenal,Tottenham";

var liga = "Barcelona,Real Madrid,Valencia,Mallorca";

var seriea = "Roma,Inter Milan,AC Milan,Sampdoria";

var eplArray = new Array();

eplArray = epl.split(",");

var ligaArray = new Array();

ligaArray = liga.split(",");

var serieaArray = new Array();

serieaArray = seriea.split(",");

function loadData(dropdownField) {

if (!(form1.page1.subform1.league.isNull)) {

switch (form1.page1.subform1.league.rawValue) {

case "English Premier League":

for (var i=0; i < eplArray.length; i++) {

dropdownField.addItem(eplArray[i]);

}

break;

case "Spanish Liga":

for (var i=0; i < ligaArray.length; i++) {

dropdownField.addItem(ligaArray[i]);

}

break;

case "Italian Serie A":

for (var i=0; i < serieaArray.length; i++) {

dropdownField.addItem(serieaArray[i]);

}

break;

default:

break;

}

}

}

Deborah

Avatar

Level 1

See the attached form, open it in Adobe Designer and open the Hierarchy

option, the script can be found in a sub form under variables.

Keadin Parish

Office Manager

Resolution Management Consultants, Inc.

1111 Exposition Blvd., Suite 602

Sacramento, CA 95815

Phone (916)922-2000 ext. 101

Fax (916)922-2022

k.parish@resmgt.com

Resolution Management Consultants Inc.

The information transmitted is intended only for the person or entity to

which it is addressed and may contain confidential and/or privileged

material. Any review, retransmission, dissemination or other use of, or

taking of any action in reliance upon this information by persons or

entities other than the intended recipient is prohibited. If you received

this in error, please contact the sender and delete the material from any

computer.

Avatar

Level 1

Wordty,

I am soooo lost. Yes I am using Adobe LiveCycle Designer that was a part of CS3 Design Premium. I dont think it is "ES" since I dont even know what ES is.

I opened "LinkedDropdowns.pdf" in Designer. But, when I select a dropdown, I dont see any code. All the code you wrote just now is all French to me. I am just trying to figure out what I need to do to get to the code. I need to change the names of the dropdowns and their lists. AND I need to add more dropdowns that link to one or more previous ones.

Avatar

Level 1

k.parish,

I found that, but how do you open it to change it? I see countryScript but no idea how to change whats inside it.

Avatar

Level 1

You need to expand the window at the top of the screen where the scripts are

written

Keadin Parish

Avatar

Level 2

To see the script object go to your top nav bar and click on window and click on Hierarchy. If it doesn't automatically open the "left" side and display your form and all its parts there should be a collapsed arrow that if you hover your mouse over you should be able to open that window. In the hierarchy at the bottom you should see the "myScriptObject". Now to see the code that is in this script, right above your form in deisgner there "should" be another collapsed arrow. This is your code window. Click on the arrow and it should open the code window. Remember to see the code that this particular object has behind it and on which event it is executed you have to highlight an object in the hierarchy or on the form. Hope this helps.

Deborah

Avatar

Level 1

Thank you...  I found the code and when I select an item in the hierarchy list, the line for the start of the cose is highlighted. However, I found the code in a different place. Under the view menu. I selected "XML Source" and it opened another tab between "Design View" and "Preview PDF".

Now the hard part begins.... Finding exactly what to copy into my forms and change. If you feel like giving me some direction on this I could attach a form with empty dropdowns.

Wish me luck ...

Avatar

Level 2

Send it along and I'll see what I can do.  I do think that editing the XML is not the approach that I would take.  I think you need to take a look at the form with the two dropdowns on it.  Show the Hierarchy window like I said and then find the code window which will have a little arrow to collapse and expand just like the hierarchy window.  Once you expose that code window and you click in the hierarchy window on the script object at the bottom you will immediately see the code that was input into this script.  I'll try to do some screen shots for you so that you know what I meancodeWindownOpen.pngcodeWindow.png

Deborah

Avatar

Level 1

Thank you Soooooo much ...  The window is called the script editor and it wasnt checked on. So, IS it this script I need to copy, paste, and change?

On MY form, the one I am trying to make, I cant put in any script, the window is gray and the PLUS icon to add script is also gray.

Avatar

Level 2

If you are attempting to create the variable in your form Click on File, Form Properties and then click on the Variables Tab. Click the + to add a new variable. Name it and then paste your code from the "myScriptObject" variable into your new variable. Make whatever changes to reference your objects. Click ok. It will show in the Hierarchy window now and if you highlight it and display the script window the code should show there also.

Deborah

"Life is half spent before we know what it is."

George Herbert

Avatar

Level 1

This is not working.

I imported a pdf specsheet and inserted dropdowns (6) in the places I need them. Then I went to add a variable like you said, I clicked on the plus sign, named it "pyramidScript", then pased in the script from the countryScript on that examply form. However, the script window remains gray with nothing in it.

Avatar

Level 2

If you will send me a copy of your form I'll take a look. dworst@gaic.com

Deborah

"Life is half spent before we know what it is."

George Herbert