Known Participant
February 23, 2020
Answered
How to populate a second figure from drop down box
- February 23, 2020
- 1 reply
- 1890 views
I have a form with dropdown box, basically, I want to auto-populate some data when user click on a particular dropdown item i.e if he selects "Acke, Yvonne" via dropdown then telephone filed will auto filed a phone number which I have a complete list of name and telephone number:
PS: I have a script but not sure what's wrong and not working for me?
Custom Keystroke
if( event.willCommit ) {
if(event.value == "") this.resetForm(["DeptContact","DeptEmail","DeptNumber"]); else SetFieldValues(event.value);
}
“SetFieldValues”
Document Processing > Document JavaScripts
// Place all pre-population data into a single data structure
var DeptData = { Accounting:{ contact: "Steala Damuni", email: "accounting@mycomp.com", deptnum: "cmp1234" }, Engineering:{ contact: "Frank N. Stien", email: "engineering@mycomp.com", deptnum: "eng1234" }, Marketing :{ contact: "Shelly Oughtbuks", email: "marketing@mycomp.com", deptnum: "mkt1234" }, ITSupport:{ contact: "Goah Wei", email: "it@mycomp.com", deptnum: "its1234" }};
function SetFieldValues(cDeptName) {
// Populate fields with values from the Department Data Object
this.getField("DeptContact").value = DeptData[cDeptName].contact;
this.getField("DeptEmail").value = DeptData[cDeptName].email;
this.getField("DeptNumber").value = DeptData[cDeptName].deptnum;
}
