I have developed a form in LiveCycle ES4 which I then make an Adobe Reader compatible PDF, and need some help. The first page of the form is essentially a data set which has predetermined fields. On the second page there is a button which takes all of the data entered from the first page and generates a written report based on that data. At the beginning of the script I have a dialog box pop up which collects some information from the user, specifically with two dropdown lists and two editable text fields.
I've managed to store the string value from the two editable text fields, but cannot figure out how to store the string from the selected items in the dropdown lists. How can I accomplish this? I'm a beginner to JavaScript and thusfar know what I know simply to create this form, so I appreciate any guidance. Thank you!
Here is my code for the dialog box:
function dialog() { var dialogDescriptor = { description: { name: "dailog1", align_children: "align_distribute", margin_width: 20, margin_height: 20, elements: [ { type: "cluster", item_id: "clu1", align_children: "align_left", alignment: "align_center", name: "Enter location of evaluation:", bold: true, elements: [ { type: "view", align_children: "align_distribute", elements: [ { type: "static_text", alignment: "align_center", name: "State:", }, { width: 80, height: 22, type: "popup", item_id: "pop1", alignment: "align_center", }, { type: "static_text", alignment: "align_center", name: "County:", }, { width: 125, height: 22, type: "popup", item_id: "pop2", alignment: "align_center", } ] }, { type: "view", align_children: "align_left", elements: [ { type: "static_text", name: "Place: (ex: Memorial Hermann Hospital)", }, { width: 385, height: 22, type: "edit_text", item_id: "edi1", } ] } ] }, { type: "cluster", align_children: "align_distribute", name: "How do you want to refer to the subject?", elements: [ { width: 385, height: 22, type: "edit_text", item_id: "edi2", } ] }, { type: "ok_cancel", alignment: "align_top", ok_name: "Create Narrative", } ] }, initialize : function(dialog) { dialog.load({ "pop1": dialogObject.pop1, "pop2": dialogObject.pop2, "edi1": dialogObject.edi1, "edi2": dialogObject.edi2, }); }, validate : function(dialog) { //add validate code here return true; }, commit : function(dialog) { var elements = dialog.store(); dialogObject.pop1 = elements["pop1"].options[elements["pop1"]].text; dialogObject.pop2 = elements["pop2"]; dialogObject.edi1 = elements["edi1"]; dialogObject.edi2 = elements["edi2"]; }, "clu1" : function(dialog) { }, "pop1": function (dialog) { var lst1 = dialog.store()["pop1"]; for (var item in lst1) { if (lst1[item] > 0) { var selectedValue = item; break; } } if (selectedValue == "Alabama") { dialog.load( { "pop2": ({"Autauga": 1, "Baldwin": -1, "Barbour": -2, "Bibb": -3, "Blount": -4, "Bullock": -5, "Butler": -6, "Calhoun": -7, "Chambers": -8, "Cherokee": -9, "Chilton": -10, "Choctaw": -11, "Clarke": -12, "Clay": -13, "Cleburne": -14, "Coffee": -15, "Colbert": -16, "Conecuh": -17, "Coosa": -18, "Covington": -19, "Crenshaw": -20, "Cullman": -21, "Dale": -22, "Dallas": -23, "DeKalb": -24, "Elmore": -25, "Escambia": -26, "Etowah": -27, "Fayette": -28, "Franklin": -29, "Geneva": -30, "Greene": -31, "Hale": -32, "Henry": -33, "Houston": -34, "Jackson": -35, "Jefferson": -36, "Lamar": -37, "Lauderdale": -38, "Lawrence": -39, "Lee": -40, "Limestone": -41, "Lowndes": -42, "Macon": -43, "Madison": -44, "Marengo": -45, "Marion": -46, "Marshall": -47, "Mobile": -48, "Monroe": -49, "Montgomery": -50, "Morgan": -51, "Perry": -52, "Pickens": -53, "Pike": -54, "Randolph": -55, "Russell": -56, "St. Clair": -57, "Shelby": -58, "Sumter": -59, "Talladega": -60, "Tallapoosa": -61, "Tuscaloosa": -62, "Walker": -63, "Washington": -64, "Wilcox": -65, "Winston": -66}) }); } else if (selectedValue == "Alaska") { dialog.load( { "pop2": ({"Aleutians East": 1, "Aleutians West": -1, "Anchorage": -2, "Bethel": -3, "Bristol Bay": -4, "Denali": -5, "Dillingham": -6, "Fairbanks North Star": -7, "Haines": -8, "Juneau": -9, "Kenai Peninsula": -10, "Ketchikan Gateway": -11, "Kodiak Island": -12, "Lake And Peninsula": -13, "Matanuska-Susitna": -14, "Nome": -15, "North Slope": -16, "Northwest Arctic": -17, "Prince of Wales-Outer Ketchikan": -18, "Sitka": -19, "Skagway": -20, "Southeast Fairbanks": -21, "Valdez-Cordova": -22, "Wade Hampton": -23, "Wrangell": -24, "Yakutat": -25}) }); } }, "pop2" : function(dialog) { }, "edi1" : function(dialog) { }, "edi2" : function(dialog) { }, }; var dialogObject = { pop1: ({' ':1, Alabama:-1, Alaska:-1, Arizona:-2, Arkansas:-3, California:-4, Colorado:-5, Connecticut:-6, Delaware:-7, Florida:-8, Georgia:-9, Hawaii:-10, Idaho:-11, Illinois:-12, Indiana:-13, Iowa:-14, Kansas:-15, Kentucky:-16, Louisiana:-17, Maine:-18, Maryland:-19, Massachusetts:-20, Michigan:-21, Minnesota:-22, Mississippi:-23, Missouri:-24, Montana:-25, Nebraska:-26, Nevada:-27, 'New Hampshire':-28, 'New Jersey':-29, 'New Mexico':-30, 'New York':-31, 'North Carolina':-32, 'North Dakota':-33, Ohio:-34, Oklahoma:-35, Oregon:-36, Pennsylvania:-37, 'Rhode Island':-38, 'South Carolina':-39, 'South Dakota':-40, Tennessee:-41, Texas:-42, Utah:-43, Vermont:-44, Virginia:-45, Washington:-46, 'West Virginia':-47, Wisconsin:-48, Wyoming:-49}), pop2: ({}), edi1: "", edi2: "SUBJECT", execDialog: function() { return app.execDialog(dialogDescriptor); }, selectedItem: function (control) { if (typeof (control) === "string") { control = this[control]; } for (var item in control) { if (typeof (control[item]) === "object") { var r = this.selectedItem(control[item]);if (r !== undefined){ return r; }} else { if (control[item] > 0){return control[item];}}}} }; return dialogObject; } var d = dialog(); d.execDialog(); var stateres = d.pop1; var countyRes = d.pop2; var placeRes = d.edi1; var nRes = d.edi2;
Solved! Go to Solution.
Views
Replies
Total Likes
Listboxes and popups return their selected value(s) as sparse arrays.
See here for an example https://answers.acrobatusers.com/Geting-user-selection-from-execDialog-popup-list-q127127.aspx
check the commit in this sample - they use a loop to find the element of the list which is not 0
Listboxes and popups return their selected value(s) as sparse arrays.
See here for an example https://answers.acrobatusers.com/Geting-user-selection-from-execDialog-popup-list-q127127.aspx
check the commit in this sample - they use a loop to find the element of the list which is not 0