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

How to populate a second figure from drop down box

Explorer ,
Feb 23, 2020 Feb 23, 2020

Copy link to clipboard

Copied

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

 

TOPICS
Acrobat SDK and JavaScript

Views

878

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

correct answers 1 Correct answer

Community Expert , Feb 24, 2020 Feb 24, 2020

If the value contains spaces you must put it within double-quotes.

Votes

Translate

Translate
Community Expert ,
Feb 23, 2020 Feb 23, 2020

Copy link to clipboard

Copied

The names of the items in the DeptData literal object have to match the items in the drop-down field.

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
Explorer ,
Feb 24, 2020 Feb 24, 2020

Copy link to clipboard

Copied

Yes, those all items are matching with the drop-down box but not working? 

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
Community Expert ,
Feb 24, 2020 Feb 24, 2020

Copy link to clipboard

Copied

They are not matching in the file you shared.

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
Explorer ,
Feb 24, 2020 Feb 24, 2020

Copy link to clipboard

Copied

I am sorry I am new to all of these coding world 😞 could you please explain a little more briefly or maybe do one example if possible? 

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
Explorer ,
Feb 24, 2020 Feb 24, 2020

Copy link to clipboard

Copied

I have some updates, I have managed to work the script please see the form with script HERE but there is one issue it will populate only single line dropdown item, for example, I have "Acke, Yvonne" but when I enter this item to script it won't word instead "Acke" is working fine? 

So, there is something wrong with this script or am I doing wrong? 

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
Community Expert ,
Feb 24, 2020 Feb 24, 2020

Copy link to clipboard

Copied

LATEST

If the value contains spaces you must put it within double-quotes.

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