Highlighted

Dynamic dropdown list using javascript for multiple times in same document

New Here ,
Jul 10, 2020

Copy link to clipboard

Copied

Hey all, I am trying to create a dynamic dropdown list in Acrobat. I was able to find many resources online using a javascript and happily got it to work! Unfortunately, I need to use the same dynamic drop down 8 times in the same form (you can select up to 8 answers off of the same extensive list). I thought I could just rename the fields and duplicate the script but it doesn't seem to work that way and each new field just replaces the same answer box). Can you please help! I assume it will take come coding knowledge which I do not posess! thanks in advance, below is a screenshot of the forms so it makes more sense and attached is the script since it is so long- it is the exact same info twice with the field changed to #2 but it didn't work for me

Screen Shot 2020-07-10 at 2.49.46 AM.png

 

Topics

Acrobat SDK and JavaScript, How to, PDF forms

Views

140

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

Dynamic dropdown list using javascript for multiple times in same document

New Here ,
Jul 10, 2020

Copy link to clipboard

Copied

Hey all, I am trying to create a dynamic dropdown list in Acrobat. I was able to find many resources online using a javascript and happily got it to work! Unfortunately, I need to use the same dynamic drop down 8 times in the same form (you can select up to 8 answers off of the same extensive list). I thought I could just rename the fields and duplicate the script but it doesn't seem to work that way and each new field just replaces the same answer box). Can you please help! I assume it will take come coding knowledge which I do not posess! thanks in advance, below is a screenshot of the forms so it makes more sense and attached is the script since it is so long- it is the exact same info twice with the field changed to #2 but it didn't work for me

Screen Shot 2020-07-10 at 2.49.46 AM.png

 

Topics

Acrobat SDK and JavaScript, How to, PDF forms

Views

141

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
Adobe Community Professional ,
Jul 10, 2020

Copy link to clipboard

Copied

You must also change the field names in the script.

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...
New Here ,
Jul 10, 2020

Copy link to clipboard

Copied

so do you mean I can't have the same field names 8 times and have them be chosen independently of each other? I guess a work around could be to add a numberal number in front of each set matching the question number?

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...
Adobe Community Professional ,
Jul 10, 2020

Copy link to clipboard

Copied

I mean the names of the fields with the answer box.

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...
New Here ,
Jul 13, 2020

Copy link to clipboard

Copied

sorry I am still lost but I probably didn't explain correctly! I am basically trying to get different values to show up for multiple combo box drops downs but each one has the same options. Competency 1, Competency 2....Competency 8. 

 

After reasearching a bit more I found this helpful post:https://answers.acrobatusers.com/How-do-I-get-different-values-to-show-up-for-multiple-combo-box-dro... but I can't quite figure out the function described....

 

My javascript knowledge just isn't good enough to figure it out! Help! thank you!!!!

 

here is my full updated javascript:

 

// Place all pre-population data into a single data structure

var DeptData = {

"Action Oriented":{ descrip: "Enjoys working hard; is action oriented and full of energy for the things he/she sees as challenging; not fearful of acting with a minimum of planning; seizes more opportunities than others." },

 

"Approachability":{ descrip: "Is easy to approach and talk to; spends the extra effort to put others at ease; can be warm, pleasant, and gracious; is sensitive to and patient with the interpersonal anxieties of others; builds rapport well; is a good listener; is an early knower, getting informal and incomplete information in time to do something about it." },

 

"Business Acumen":{ descrip: "Knows how businesses work; knowledgeable in current and possible future policies, practices, trends, and information affecting his/her business and organization; knows the competition; is aware of how strategies and tactics work in the marketplace." },

 

"Comfort Around Higher Management":{ descrip: "Can deal comfortably with more senior managers; can present to more senior managers without undue tension and nervousness; understands how senior managers think and work; can determine the best way to get things done with them by talking their language and responding to their needs; can craft approaches likely to be seen as appropriate and positive."},

 

"Composure":{ descrip: "Is cool under pressure; does not become defensive or irritated when times are tough; is considered mature; can be counted on to hold things together during tough times; can handle stress; is not knocked off balance by the unexpected; does not show frustration when resisted or blocked; is a settling influence in a crisis." },

 

"Conflict Management":{ descrip: "Steps up to conflicts, seeing them as opportunities; reads situations quickly; good at focused listening; can hammer out tough agreements and settle disputes equitably; can find common ground and get cooperation with minimum noise." },

 

"Creativity":{ descrip: "Comes up with a lot of new and unique ideas; easily makes connections among previously unrelated notions; tends to be seen as original and value-added in brainstorming settings." },

 

"Customer Focus":{ descrip: "Is dedicated to meeting the expectations and requirements of internal and external customers; gets first-hand customer information and uses it for improvements in products and services; acts with customers in mind; establishes and maintains effective relationships with customers and gains their trust and respect." },

 

"Dealing with Ambiguity":{ descrip: "Can effectively cope with change; can shift gears comfortably; can decide and act without having the total picture; is not upset when things are up in the air; doesn’t have to finish things before moving on; can comfortably handle." },

 

"Decision Quality":{ descrip: "Makes good decisions (without considering how much time it takes) based upon a mixture of analysis, wisdom, experience, and judgment; most of his/her solutions and suggestions turn out to be correct and accurate when judged over time; sought out by others for advice and solutions." },

 

"Drive For Results":{ descrip: "Can be counted on to exceed goals successfully; is constantly and consistently one of the top performers; very bottom-line oriented; steadfastly pushes self and others for results." },

 

"Functional/Technical Skills":{ descrip: "Has the functional and technical knowledge and skills to do the job at a high level of accomplishment." },

 

"Integrity and Trust":{ descrip: "Is widely trusted; is seen as a direct, truthful individual; can present the unvarnished truth in an appropriate and helpful manner; keeps confidences; admits mistakes; doesn’t misrepresent him/herself for personal gain." },

 

"Intellectual Horsepower":{ descrip: "Is bright and intelligent; deals with concepts and complexity comfortably; described as intellectually sharp, capable, and agile." },

 

"Interpersonal Savvy":{ descrip: "Relates well to all kinds of people, up, down, and sideways, inside and outside the organization; builds appropriate rapport; builds constructive and effective relationships; uses diplomacy and tact; can diffuse even high-tension situations comfortably." },

 

"Learning on the Fly":{ descrip: "Learns quickly when facing new problems; a relentless and versatile learner; open to change; analyzes both successes and failures for clues to improvement; experiments and will try anything to find solutions; enjoys the challenge of unfamiliar tasks; quickly grasps the essence and the underlying structure of anything." },

 

"Listening":{ descrip: "Practices attentive and active listening; has the patience to hear people out; can accurately restate the opinions of others even when he/she disagrees." },

 

"Managing Diversity":{ descrip: "Manages all kinds and classes of people equitably; deals effectively with all races, nationalities, cultures, disabilities, ages and both sexes; hires variety and diversity without regard to class; supports equal and fair treatment and opportunity for all." },

 

"Negotiating":{ descrip: "Can negotiate skillfully in tough situations with both internal and external groups; can settle differences with minimum noise; can win concessions without damaging relationships; can be both direct and forceful as well as diplomatic; gains trust quickly of other parties to the negotiations; has a good sense of timing." },

 

"Organizational Agility":{ descrip: "Knowledgeable about how organizations work; knows how to get things done both through formal channels and the informal network; understands the origin and reasoning behind key policies, practices, and procedures; understands the cultures of organizations." },

 

"Organizing":{ descrip: "Can marshal resources (people, funding, material, support) to get things done; can orchestrate multiple activities at once to accomplish a goal; uses resources effectively and efficiently arranges information and files in a useful manner." },

 

"Patience":{ descrip: "Is tolerant with people and processes; listens and checks before acting; tries to understand the people and the data before making judgments and acting; waits for others to catch up before acting; sensitive to due process and proper pacing; follows established process." },

 

"Peer Relationships":{ descrip: "Can quickly find common ground and solve problems for the good of all; can represent his/her own interests and yet be fair to other groups; can solve problems with peers with a minimum of noise; is seen as a team player and is cooperative; easily gains trust and support of peers; encourages collaboration; can be candid with peers." },

 

"Perseverance":{ descrip: "Pursues everything with energy, drive, and a need to finish; seldom gives up before finishing, especially in the face of resistance or setbacks." },

 

"Perspective":{ descrip: "Looks toward the broadest possible view of an issue/challenge; has broad-ranging personal and business interests and pursuits; can easily pose future scenarios; can think globally; can discuss multiple aspects and impacts of issues and project them into the future." },

 

 

"Planning":{ descrip: "Accurately scopes out length and difficulty of tasks and projects; sets objectives and goals; breaks down work into the process steps; develops schedules and task/people assignments; anticipates and adjusts for problems and roadblocks; measures performance against goals; evaluates results." },

 

 

"Presentation Skills":{ descrip: "Is effective in a variety of formal presentation settings: one-on-one, small and large groups, with peers, direct reports, and bosses; is effective both inside and outside the organization, on both cool data and hot and controversial topics; commands attention and can manage group processes during the presentation; can change tactics midstream when something is not working." },

 

"Priority Setting":{ descrip: "Spends his/her time and the time of others on what’s important; quickly zeros in on the critical few and puts the trivial many aside; can quickly sense what will help or hinder accomplishing a goal; eliminates roadblocks; creates focus." },

 

"Problem Solving":{ descrip: "Uses rigorous logic and methods to solve difficult problems with effective solutions; probes all fruitful sources for answers; can see hidden problems; is excellent at honest analysis; looks beyond the obvious and doesn't stop at the first answers." },

 

"Process Management":{ descrip: "Good at figuring out the processes necessary to get things done; knows how to organize people and activities; understands how to separate and combine tasks into efficient work flow; knows what to measure and how to measure it; can see opportunities for synergy and integration where others can't; can simplify complex processes; gets more out of fewer resources." },

 

"Self-Development":{ descrip: "Is personally committed to and actively works to continuously improve him/herself; understands that different situations and levels may call for different skills and approaches; works to deploy strengths; works on compensating for weakness and limits." },

 

"Strategic Agility":{ descrip: "Sees ahead clearly; can anticipate future consequences and trends accurately; has broad knowledge and perspective; is future oriented; can articulately paint credible pictures and visions of possibilities and likelihoods; can create competitive and breakthrough strategies and plans." },

 

"Technical Learning":{ descrip: "Picks up on technical things quickly; can learn new skills and knowledge; is good at learning new industry, company, product, or technical knowledge; does well in technical courses and seminars." },

 

"Time Management":{ descrip: "Uses his/her time effectively and efficiently; values time; concentrates his/her efforts on the more important priorities; gets more done in less time than others; can attend to a broader range of activities." },

 

"Effective Communication":{ descrip: "The ability to ensure that information is passed onto others who should be kept informed. The ability to express oneself clearly in conversations and interactions. Is able to write clearly and succinctly in a variety of communication settings and styles; can get messages across that have the desired effect. Respects the confidentiality and/or sensitivity of information or concerns shared by others and if sharing, is certain of the truth." },

 

"Ethics and Values":{ descrip: "Adheres to an appropriate (for the setting) and effective set of core values and beliefs during both good and bad times; acts in line with those values; rewards the right values and disapproves of others; practices what he/she preaches." },

 

"M - Delegation":{ descrip: "Clearly and comfortably delegates both routine and important tasks and decisions; broadly shares both responsibility and accountability; tends to trust people to perform; lets direct reports finish their own work." },

 

"M - Developing Direct Reports":{ descrip: "Provides challenging and stretching tasks and assignments; holds frequent development discussions; is aware of each direct report’s career goals; constructs compelling development plans and executes them; pushes direct reports to accept developmental moves; will take direct reports who need work; is a people builder." },

 

"M - Managerial Courage":{ descrip: "Doesn’t hold back anything that needs to be said; provides current, direct, complete, and “actionable” positive and corrective feedback to others; lets people know where they stand; faces up to people problems on any person or situation (not including direct reports) quickly and directly; is not afraid to take negative action when necessary." },

 

"M - Managing and Measuring Work":{ descrip: "Clearly assigns responsibility for tasks and decisions; sets clear objectives and measures; monitors process, progress, and results; designs feedback loops into work." },

 

"M - Building Effective Teams":{ descrip: "Blends people into teams when needed; creates strong morale and spirit in his/her team; shares wins and successes; fosters open dialogue; lets people finish and be responsible for their work; defines success in terms of the whole team; creates a feeling of belonging in the team." },

 

"M - Fiscal Responsibility":{ descrip: "Fiscal Responsibility: Exercises acceptable budgetary control and demonstrates a knowledge of budget planning and principles." },

 

"M - Employee Relations":{ descrip: "Demonstrates good judgement when making hiring, promotion, termination and evaluation decisions." },

 

"M - Total Quality Management/Re-Engineering":{ descrip: "Is dedicated to providing the highest quality products and services which meet the needs and requirements of internal and external customers; is committed to continuous improvement through empowerment and management by data; is willing to re-engineer processes from scratch; is open to suggestions and experimentation; creates a learning environment leading to the most efficient and effective work processes." },

 

"M - Timely Decision Making":{ descrip: "Makes decisions in a timely manner, sometimes with incomplete information and under tight deadlines and pressure; able to make a quick decision." }, 

 

"M - Informing":{ descrip: "Provides the information people need to know to do their jobs and to feel good about being a member of the team, unit, and/or the organization; provides individuals information so that they can make accurate decisions; is timely with information." },

 

 

};

 

function SetFieldValues(cCompetency1only,descripName)

{

var i = descripName.substr(descripName.length-1,1);

    this.getField("description"+1).value = DeptData[cCompetency1only].descrip;

}

 

 

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...
Adobe Community Professional ,
Jul 13, 2020

Copy link to clipboard

Copied

The code isn't using the row number, "i".  

Try this:

 

function SetFieldValues(cCompetency1only,descripName)
{
    var i = descripName.substr(descripName.length-1,1);
    this.getField("description"+i).value = DeptData[cCompetency1only].descrip;
}

 

However, without knowing the field names and how the SetFieldValues function is called, I can't be sure this solution is correct. 

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...
Adobe Community Professional ,
Jul 13, 2020

Copy link to clipboard

Copied

May be better when you share the form.

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...
New Here ,
Jul 13, 2020

Copy link to clipboard

Copied

sorry! I just added the form to the original message above

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...
Adobe Community Professional ,
Jul 13, 2020

Copy link to clipboard

Copied

I've looked over you form and there are two issues.

1) Use the corrected code I provided for the "SetFieldValues()" function. The current code will not work because it uses hard coded field names.

 

2) The "SetFieldValues()" fucntion needs to be called differently. It needs to pass the name of the current field and the current selected value, like this:

 

SetFieldValues(event.value, event.targetName);   

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...
New Here ,
Jul 13, 2020

Copy link to clipboard

Copied

Thom, thank you so much for your reply. I think i uploaded the incorrect form earlier - the correct one is attached to the original post if you want to take a look at my javascript (RR- North Star Form 2020 drop down-v2.pdf).

 

I did try your changes in the javascript but I must be missing something. Since the Competency field is repeated I assume I need to label those as well? should I repeat the function for each but changing the name? 

 

 

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...
Adobe Community Professional ,
Jul 13, 2020

Copy link to clipboard

Copied

Ok, so there are more problems with this than I saw originally. 

Mainly the names your using are totally inconsistent. Names in any programming language must be exactly the same everywhere. Names are of course how things get matched up. 

Here's an update for the function, notice how "cCompetency" is used:

 

function SetFieldValues(cCompetency,descripName)
{
    var i = descripName.substr(descripName.length-1,1);
    this.getField("description"+i).value = DeptData[cCompetency].descrip;
}

 

  Next, the resetForm  call in the Keystroke script does not use the actual field name that needs to be reset.  And make sure you add the "event.targetName" parameter to the function call, as I showed in the previous post. 

 

Fix these two things and you should be good. 

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...
New Here ,
Jul 13, 2020

Copy link to clipboard

Copied

still no luck...none of the descriptions show up in any of the boxes when I make my choices.

I updated the Keystroke script to match the correct field (I think) and the function in the javascript. I attached my latest version (v3) to the original post.

 

I'm obviously missing something but can't figure it out!

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...
Adobe Community Professional ,
Jul 13, 2020

Copy link to clipboard

Copied

In the Javascript console I get following error:

TypeError: descripName is undefined
103:Document-Level:SetFieldValues1

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...
Adobe Community Professional ,
Jul 13, 2020

Copy link to clipboard

Copied

So again, when the function is called, there have to be two arguments passed in, as I pointed out in the early post. Like this.

 

SetFieldValues(event.value, event.targetName);

 

 

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...
Resources
One Stop Solution for Acrobat
Edit a PDF