Autopopulate blank data to a text field from a drop down list

Contributor ,
Aug 14, 2019

Copy link to clipboard

Copied

I entered the script below which works but not perfectly.  If COT or POT is picked from the drop down list I want the WO text field to be blank, which it does.  If 'Vacation' is picked the WO number "3071070" populates to the text field.  The problem is if the user changes their mind from Vacation to COT the WO number does not disappear.  Is there something I can put in the quotes to tell it I actually want a blank text field?  Thank you!!

// Place Absence Data into Pay Type Description and WO Fields

var AbsenceData = { "Vacation":{WO: "3071070",

PayTypeDesc: "Vacation" }, 

"COT":{ WO: "",

PayTypeDesc: "COT" }, 

"POT":{ WO: "",

PayTypeDesc: "POT" }, 

"Stat Holiday":{ WO: "3071070",

PayTypeDesc: "Stat Holiday" }, 

"Sick":{ WO: "3071080",

PayTypeDesc: "Sick" }, 

"Family Sick":{ WO: "3071080",

PayTypeDesc: "Family Sick" }, 

"Sick No Pay":{ WO: "3071080",

PayTypeDesc: "Sick No Pay" },                                                 

"Leave No Pay":{ WO: "3071080",

PayTypeDesc: "Leave No Pay" },                                                 

"Compassion Leave":{ WO: "3071080",

PayTypeDesc: "Compassion Leave" },                                                 

"WCB Hours":{ WO: "3071080",

PayTypeDesc: "WCB Hours" },                                                 

"WCB Sick Leave":{ WO: "3071080",

PayTypeDesc: "WCB Sick Leave" },                                                 

"Jury Duty":{ WO: "3071080",                

PayTypeDesc: "Jury Duty" },                                                 

"Union Leave":{ WO: "3071080",

PayTypeDesc: "Union Leave" }};                                                 

function SetFieldValuesAbsence1(cAbsenceName)

{

  this.getField("WO1").value = AbsenceData[cAbsenceName].WO;

  this.getField("PayTypeDesc1").value = AbsenceData[cAbsenceName].PayTypeDesc;

}

TOPICS
Acrobat SDK and JavaScript

Views

69

Likes

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

Autopopulate blank data to a text field from a drop down list

Contributor ,
Aug 14, 2019

Copy link to clipboard

Copied

I entered the script below which works but not perfectly.  If COT or POT is picked from the drop down list I want the WO text field to be blank, which it does.  If 'Vacation' is picked the WO number "3071070" populates to the text field.  The problem is if the user changes their mind from Vacation to COT the WO number does not disappear.  Is there something I can put in the quotes to tell it I actually want a blank text field?  Thank you!!

// Place Absence Data into Pay Type Description and WO Fields

var AbsenceData = { "Vacation":{WO: "3071070",

PayTypeDesc: "Vacation" }, 

"COT":{ WO: "",

PayTypeDesc: "COT" }, 

"POT":{ WO: "",

PayTypeDesc: "POT" }, 

"Stat Holiday":{ WO: "3071070",

PayTypeDesc: "Stat Holiday" }, 

"Sick":{ WO: "3071080",

PayTypeDesc: "Sick" }, 

"Family Sick":{ WO: "3071080",

PayTypeDesc: "Family Sick" }, 

"Sick No Pay":{ WO: "3071080",

PayTypeDesc: "Sick No Pay" },                                                 

"Leave No Pay":{ WO: "3071080",

PayTypeDesc: "Leave No Pay" },                                                 

"Compassion Leave":{ WO: "3071080",

PayTypeDesc: "Compassion Leave" },                                                 

"WCB Hours":{ WO: "3071080",

PayTypeDesc: "WCB Hours" },                                                 

"WCB Sick Leave":{ WO: "3071080",

PayTypeDesc: "WCB Sick Leave" },                                                 

"Jury Duty":{ WO: "3071080",                

PayTypeDesc: "Jury Duty" },                                                 

"Union Leave":{ WO: "3071080",

PayTypeDesc: "Union Leave" }};                                                 

function SetFieldValuesAbsence1(cAbsenceName)

{

  this.getField("WO1").value = AbsenceData[cAbsenceName].WO;

  this.getField("PayTypeDesc1").value = AbsenceData[cAbsenceName].PayTypeDesc;

}

TOPICS
Acrobat SDK and JavaScript

Views

70

Likes

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
Aug 14, 2019 0
Most Valuable Participant ,
Aug 14, 2019

Copy link to clipboard

Copied

The way you have it set up should work. Are you seeing any error messages in the JS Console?

Likes

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
Reply
Loading...
Aug 14, 2019 0
Contributor ,
Aug 14, 2019

Copy link to clipboard

Copied

Oh my gosh, I must have done something weird before because it didn’t work and now it does! Thanks so much for the reply Try67, you’ve been so helpful for me!

Likes

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
Reply
Loading...
Aug 14, 2019 0