Skip to main content
Inspiring
Aug 14, 2019 8:33 PM UTC
Question

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

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;

}

This topic is closed to new replies. Start a new post to keep the conversation going.

2 replies

try67
Community Expert
Community Expert
Aug 14, 2019 8:51 PM UTC

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

Translate
Inspiring
Aug 14, 2019 8:59 PM UTC

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!

Translate