JavaScript help needed for dropdown selections
I don't know if this is even possible, but I'm hoping someone out there can help me figure out a solution.
I have 2 dropdowns 1) Employee Name 2) Absence. Both populate data to the same text fields, PayType and PayTypeDesc. The user enters their name first and the data populates, and when they choose from the Absence list the data changes. That's fine, but if the user removes the absence pay type the data clears. I would like the data to populate back from Employee Name again if a selection is removed from Absence. Thank you!!
The following is the script I'm using:
//EMPLOYEE DROPDOWN LIST
if( event.willCommit )
{
if(event.value == " ")
this.resetForm(["ID","PayType","PayTypeDesc"]);
else
SetFieldValuesEmployeeName(event.value);
}
var EmployeeData = { "Case, Justin 3871 (Lieu)":{Status: "1",
PayTypeDesc: "Regular",
ID: "3871" },
"Smith, Jane 3059":{ Status: "1",
PayTypeDesc: "Regular",
ID: "3059" }};
function SetFieldValuesEmployeeName(cEmployeeName)
{
this.getField("PayType").value = EmployeeData[cEmployeeName].Status;
this.getField("PayTypeDesc").value = EmployeeData[cEmployeeName].PayTypeDesc;
this.getField("ID").value = EmployeeData[cEmployeeName].ID;
}
//ABSENCE DROPDOWN LIST
if( event.willCommit )
{
if(event.value == " ")
this.resetForm(["PayType","PayTypeDesc","WO"]);
else
SetFieldValuesAbsence(event.value);
}
// Place all Absence Pay Type Descripton into Pay Type Field
var AbsenceData = { "Vacation":{WO: "3070250",
PayTypeDesc: "Vacation",
PayType: "100" },
"COT":{ WO: "",
PayTypeDesc: "COT",
PayType: "200" },
"POT":{ WO: "",
PayTypeDesc: "POT",
PayType: "300" },
"Lieu Day":{ WO: "3070285",
PayTypeDesc: "Lieu Day",
PayType: "400" },
"Stat Holiday":{ WO: "3070250",
PayTypeDesc: "Stat",
PayType: "500" },
"Sick":{ WO: "3070275",
PayTypeDesc: "Sick",
PayType: "600" },
"Family Sick":{ WO: "3070275",
PayTypeDesc: "Family Sick",
PayType: "700" },
"Sick No Pay":{ WO: "3070275",
PayTypeDesc: "Sick No Pay",
PayType: "750" },
"Leave No Pay":{ WO: "3070275",
PayTypeDesc: "Leave No Pay",
PayType: "800" },
"Compassion Leave":{ WO: "3070275",
PayTypeDesc: "Compassion",
PayType: "900" },
"WCB Hours":{ WO: "3070275",
PayTypeDesc: "WCB",
PayType: "950" },
"WCB Sick Leave":{ WO: "3070275",
PayTypeDesc: "WCB Sick Leave",
PayType: "150" },
"Jury Duty":{ WO: "3070275",
PayTypeDesc: "Jury Duty",
PayType: "250" },
"Union Leave":{ WO: "3070275",
PayTypeDesc: "Union Leave",
PayType: "350" }};
function SetFieldValuesAbsence(cAbsenceName)
{
this.getField("WO").value = AbsenceData[cAbsenceName].WO;
this.getField("PayTypeDesc").value = AbsenceData[cAbsenceName].PayTypeDesc;
this.getField("PayType").value = AbsenceData[cAbsenceName].PayType;
}
