• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

JavaScript help needed for dropdown selections

Engaged ,
Jul 08, 2020 Jul 08, 2020

Copy link to clipboard

Copied

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;
}

TOPICS
Acrobat SDK and JavaScript

Views

170

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jul 09, 2020 Jul 09, 2020

Copy link to clipboard

Copied

LATEST

In case anyone needs to know...

I figure it out!  I added a custom calculation script in PayType field.  I was doing this before but I was going about it a bit wrong.  I was populating employees status (reg, temp etc) to PayTypeDesc and then populating everything in the custom calculation to PayType (status,vacation,acting), but I now changed it to populate employee status separately.  Now if the user removes a selection from absence or acting the employee status resets back again.  I hope that makes sense, but anyways it works great now, woot!  Now my form it bullet proof!

var a ="";
if (this.getField("PayTypeDesc").value == "COT"){
a="200";
} else if (this.getField("PayTypeDesc").value == "Vacation"){
a="100";
} else if (this.getField("PayTypeDesc").value == "Sick"){
a="200";
} else if (this.getField("PayTypeDesc").value == "Acting"){
a="11";
} else if (this.getField("Employee").value == "Sean"){
a="2";
} else if (this.getField("Employee").value == "Tracey"){
a="1";
}
event.value = a;

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines