I am (new to) using LiveCycle Designer 7 and javascript and am trying to populate 3 dependent dropdowns in a subform using a multidimensional array. I am having trouble getting the second layer of my array into the second dropdown, so I can then move on to the third. I think it may be a problem with my loop. I realize that this is a complicated task for a beginner to tackle, possibly out of the scope of this forum, but I am also open to suggestions for a better way to accomplish this task.
//Here's my array: var chooseFR = [[["California"], ["Alfalfa","Insecticide","Fungicide"], ["Asparagus", "Miticide", "Herbicide"], ["Berries", "Fungicide","Miticide"]] [["Arizona"], ["Citrus","Insecticide", "Herbicide"], ["Cole Crops", "PGR", "Herbicide"]]]; //I use this to populate the first dropdown at initialization, which works fine function getState(dropdownField) { dropdownField.clearItems(); for (var i=0; i < chooseFR.length; i++) dropdownField.addItem(chooseFR[i][0][0]); } //I am trying to use this to populate the second dropdown, but I get 3 //instances of "Empty" for California //and two instances of "Empty" for Arizona in my second dropdown function getCrop(cropField, dropdownField) { dropdownField.clearItems(); for (var i=0; i < chooseFR.length; i++) if(chooseFR[i][0] == cropField.rawValue) { for (var j=1; j < chooseFR.length; j++) { dropdownField.addItem(chooseFR[i][j]); } } } // Here is my change event for the first dropdown function getStatesOther(myXfa, dropdownField) { dropdownField.clearItems(); for (var i=0; i < chooseFR.length; i++) if(chooseFR[i][0] == myXfa.event.newText) { for (var j=1; j < chooseFR[i].length; j++) { dropdownField.addItem(chooseFR[i][j]); } } }
Sorry for the length, and thanks in advance for any help.
Shellee
For a better strategy, read both parts of this article, it covers almost exactly what you want to do:
http://www.acrobatusers.com/tutorials/2007/js_list_combo_livecycle/
Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script