Highlighted

dropdown list addItem not working using a variable field name in a custom function

Town_of_Sandwic

12-02-2015

I obviously don't know enough about javascript to figure out why addItem will not work in my custom script object using a variable "fldName" but it does work if I use the actual field name "accountNo1"?  My objective is to auto-populate thirteen drop-down lists "accountNo1, accountNo2, accountNo3" and so on.  Any help will be greatly appreciated.






function accountList(items){

var fldName = items.target.name;

switch(department.rawValue){//auto populate drop-down list based on department selection

case 'DPW - Highway':

fldName.addItem('Repair/Maintenance Equipment', '5247');

fldName.addItem('Equipment Hire', '5275');

fldName.addItem('Office Supplies', '5420');

fldName.addItem('Office Supplies', '5420');

fldName.addItem('Catch Basin', '5444');

fldName.addItem('Tools/Equipment', '5450');

fldName.addItem('Gas & Oil', '5480');

fldName.addItem('Gravel/Loam & Stone', '5531');

fldName.addItem('Street Lining', '5532');

fldName.addItem('Asphalt', '5535');

fldName.addItem('Oil/Surface Coating', '5536');

fldName.addItem('Drainage', '5537');

fldName.addItem('Sign/Mark, etc', '5539');

fldName.addItem('Uniforms', '5582');

fldName.addItem('Clothing Allowance', '5583');

fldName.addItem('Dues & Membership', '5730');

break;

case 'DPW - Parks':

fldName.addItem('Equipment Maintenance', '5247');

fldName.addItem('Equipment Hire', '5275');

fldName.addItem('Telephone', '5341');

fldName.addItem('Tree Warden Program', '5365');

fldName.addItem('Supplies', '5400');

fldName.addItem('Plants, Trees, Shrubs', '5463');

fldName.addItem('Gas & Oil', '5480');

fldName.addItem('Uniforms', '5582');

fldName.addItem('Clothing Allowance', '5583');

fldName.addItem('Dues & Membership', '5730');

break

case 'DPW - Transfer Station':

fldName.addItem('Hazardous Waste', '5224');

fldName.addItem('Equipment Maintenance', '5247');

fldName.addItem('Lease Land', '5270');

fldName.addItem('Lease Purchase Equipment', '5271');

fldName.addItem('Equipment Hire', '5275');

fldName.addItem('Testing Wells', '5381');

fldName.addItem('Office Supplies', '5420');

fldName.addItem('Purchase Fuel', '5481');

fldName.addItem('Landfill Expense', '5545');

fldName.addItem('Uniforms', '5582');

fldName.addItem('Clothing Allowance', '5583');

fldName.addItem('Transport/Bay Colony', '5533');

fldName.addItem('Tipping Fees-SEMASS', '5610');

fldName.addItem('Town of Falmouth Otis Operations', '5611');

break;

case 'DPW - Snow & Ice':

fldName.addItem('Payroll', '5119');

fldName.addItem('Equipment Maintenance', '5046');

fldName.addItem('Truck Maintenance', '5245');

fldName.addItem('Equipment Hire', '5247');

fldName.addItem('Supplies', '5400');

fldName.addItem('Gas & Oil', '5480');

fldName.addItem('Salt', '5533');

fldName.addItem('Sand', '5534');

break;

default:

items.rawValue = null;

app.alert({cMsg:'A DEPARTMENT MUST BE SELECTED BEFORE\nACCOUNT NUMBERS CAN BE DISPLAYED', nIcon:3, nType:0, cTitle:'Department Validation'});

  break;

}

}

Replies