These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Multiple Dropdown to populate 2 text boxes - I've almost got it

DustinH
Registered: Jun 22 2011
Posts: 6

I'm a complete novice to JavaScript and have complied what I can from what I've found on this forum so far. I almost have my script working, but I'm missing something. Using Acrobat X Pro.
 
Basically, the form is meant to pick a department from one drop down, a position from another, and that position will populate the two text fields with required equipment and accounts (form for tracking employee equipment and accounts).
  
To achieve this, I created one drop down with all the departments, and have separate dropdowns for each department to select the positions. I originally tried to have the department dropdown populate a single dropdown with that departments specific positions. I got that to work, but couldn't figure out how to then make the position one populate the text boxes.
 
So what I have now is a drop down for each department which contains the positions and just hide / show them based on the department selected. I then used a script to populate the text boxes based on the position selection, which is working.
 
My problem is I can't get multiple departments to work. The script will allow a single dropdown to populate the text fields, and the others do nothing.
 
Here is the script I'm using with only 2 departments (haven't added more since I can't get the two working). Right now, this scrip will populate the Admin and InformationSystems dropdowns with the correct position. The admin one will populate the text fields EquipText and AccountText as intended, but the InfoSys one will not populate the text boxes at all.
  
I really really appreciate any help anyone can give!
      
//*****************************************************************************************
//ADMIN
  
//First make the values for Admin Department.
 
myAdminValues = ["", "CEO", "CFO", "Assistant"];
  
//Then populate the values to Admin Department.
 
this.getField("Admin").setItems(myAdminValues);
   
// Then you define what has to be shown in textboxes when value is selected
 
var AdminData = { CEO:{ equip: "Blackberry" ,
account: "Raiser's Edge, Crossnet, ProxCard" },
CFO:{ equip: "Laptop, Blackberry, Keys, ProxCard, ADP",
account: "Raiser's Edge, ISIS, Crossnet" } ,
Assistant :{ equip: "Laptop, Blackberry",
account: "Raiser's Edge, Crossnet, CEO Email" }
};
  
//Finally set the values of the textboxes
 
function SetFieldValues(cDeptName2)
 
{
 
this.getField("EquipText").value = AdminData[cDeptName2].equip;
this.getField("AccountText").value = AdminData[cDeptName2].account;
}
       
//*****************************************************************************************
//INFORMATION SYSTEMS
  
//First make the values for Infosys Department.
 
myInfoSysValues = ["", "Manager", "Coordinator", "Associate"];
  
//Then populate the values to Infosys Department.
 
this.getField("InformationSystems").setItems(myInfoSysValues);
   
// Then define what has to be shown in the textboxes when value is selected
 
var InfoSysData = { Manager:{ equip: "Laptop, Blackberry" ,
account: "Raiser's Edge, ISIS, Extranet, Crossnet" },
Coordinator:{ equip: "Laptop, Blackberry, Keys",
account: "Raiser's Edge, ISIS, Extranet, Crossnet" } ,
Associate :{ equip: "Laptop",
account: "Raiser's Edge, ISIS, Extranet, Crossnet" }
};
  
//set the values of the textboxes
 
function SetFieldValues(cDeptName1)
 
{
 
this.getField("EquipText").value = InfoSysData[cDeptName1].equip;
this.getField("AccountText").value = InfoSysData[cDeptName1].account;
}
 

My Product Information:
Acrobat Pro 10.1, Windows
DustinH
Registered: Jun 22 2011
Posts: 6
Any suggestions?
Caroline
Registered: Jun 22 2011
Posts: 10
Dustin, I'm in research mode myself, so I haven't looked closely at your script. But have you checked out this article: http://acrobatusers.com/tutorials/2007/js_list_combo_livecycle/ (Programming List and Combo fields in Acrobat and LiveCycle forms - Part 1)?

I needed to populate a second combo box based on the value in the first one, which it sounds like you've already figured out how to do; I got most of what I needed from that article.

But then I also had to make a block of fields active based on the value selected in the first combo box as well. I had a heck of a time with it until I used the same "if (!event.willCommit)" statement that he uses in that article, and called it from a custom keystroke script on the Format tab.

Don't know if that's got anything to do with your issue or not, but I thought I'd pass it on just in case. I'm learning javascript by trial and error too ;-)

Caroline