Copy link to clipboard
Copied
Hello all. I am trying to create a field in one of my forms using Adobe Acrobat Pro XI. I have a dropdown list of "main" items, and based on what is selected in that list, I want a second dropdown list to give different choices. I have searched and searched and have javascript that I thought might work, but maybe I am have a mistake or I am placing the javascript in the wrong place, becasue it is not working. I know very, very little about javascript, so any help would be so much appreciated.
I am using Adobe Acrobat Pro XI. I added a "new field", and selected "dropdown". The field name is ProvType. The dropdown options are:
Inpatient
Outpatient
Physician
I have the "Commit selected value immediately" selected.The field is not validated. The format is "none." There are no actions or calculations associated with it.
I then created another dropbox, and named it SubProvType. Under Actions, I selected the trigger as Mouse Up, and then selected the Action "Run a JavaScript." I selected the add button, and typed this in the JavaScript editor:
switch (ProvType.rawValue)
{
case "Inpatient":
this.setItems("Hospice,Hospital,Nursing Facility");
break;
case "Outpatient":
this.setItems("Adult Day Center,Home,Other");
break;
case "Physician":
this.setItems("Surgeon,Family Practice,Neurologist");
break;
}
What I want to happen is:
If "Inpatient" is selected, I want the following options to be available in the second dropdown box "SubProvType":
Hospice
Hospital
Nursing Facility
If "Outpatient" is selected, I want the following options to be available in the second dropdown box "SubProvType":
Adult Day Center
Home
Other
If "Physician" is selected, I want the following options to be available in the second dropdown box "SubProvType":
Surgeon
Family Practice
Neurologist
However.... when I close the form editing and try to select a different option in the ProvType field, the SubProvType field remains blank and there are no options available. There are also no errors.
I must be missing something, but I have no idea where to start. Thank you in advance for any help anyone can provide.
Use this code as the custom validation script of ProvType (and remove any code you associated with SubProvType):
...switch (event.value) {
case "Inpatient":
this.getField("SubProvType").setItems(["Hospice,Hospital,Nursing Facility"]);
break;
case "Outpatient":
this.getField("SubProvType").setItems(["Adult Day Center,Home,Other"]);
break;
case "Physician":
this.getField("SubProvType").setItems(["Surgeon,Family Practice,Neurologist"]);
br
Copy link to clipboard
Copied
Do you mean an export value to the items in the drop-down, or an additional item to the possible selections that you're setting, or a new "category", etc.? Please clarify.
Copy link to clipboard
Copied
ill would like a value added to eg .. "hospice" with value of 2.
and "hospital" with value of 30.
Copy link to clipboard
Copied
OK, then you need to adjust the code like this:
this.getField("SubProvType").setItems([["Hospice", "2"],["Hospital", "30"],["Nursing Facility", "99"]]);
Copy link to clipboard
Copied
OH WOW!!!!!! You are the biggest legend Ever...... You have made my day!!!! So simple.
Copy link to clipboard
Copied
Can i use a list from excel or any list to do the same thing?
1 GANG SWITCH W/ MECH 10A | $15.00 | |||
1 GANG PLATE | $7.50 | |||
2 GANG SWITCH W/ MECH 10A | $20.00 | |||
2 GANG PLATE | $8.50 | |||
3 GANG SWITCH W/ MECH 10A | $30.00 | |||
3 GANG PLATE | $10.00 | |||
4 GANG SWITCH W/ MECH 10A | $45.00 | |||
4 GANG PLATE | $15.00 | |||
5 GANG SWITCH W/ MECH 10A | $55.00 | |||
5 GANG PLATE | $20.00 | |||
6 GANG SWITCH W/ MECH 10A | $70.00 | |||
6 GANG PLATE | $25.00 | |||
BLANK PLATE | $7.50 | |||
DOUBLE GPO 10A | $15.00 | |||
DOUBLE GPO 10A W/ SWITCH | $50.00 | |||
SINGLE GPO W/ 2X SWITCH | $60.00 | |||
SINGLE 15A GPO | $40.00 | |||
WEATHERPROOF 1 GANG SWITCH | $35.00 | |||
WEATHERPROOF DOUBLE GPO | $45.00 | |||
WEATHERPROOF SINGLE GPO | $40.00 | |||
WEATHERPROOF 40A ISOLATOR 1P 240V | $50.00 | |||
WEATHERPROOF 40A ISOLATOR 3P 500V | $70.00 |
Copy link to clipboard
Copied
Yes, it is possible to import the values from an external file (although the file needs to be a plain-text file), even including the export values, but that requires a more complex script, like this one I've developed: Custom-made Adobe Scripts: Acrobat -- Import Items from a Text File to a Combo-Box or List Field
Copy link to clipboard
Copied
I hope I am not hijacking this thread, I can't seem to have the simplest of things working in my Acrobat form...
The only code I have is :
getField("Dropdown1").setItems(["a","b","c"]);
This gives my field "Dropdown1" the three options to choose from, but on clicking for example "c" the selection always resets itself at "a". I am quite dumbfounded by this behavior.
EDIT: Apparently this is because the code is in a text field that executes constantly (?) because putting it in a button that has to be pressed solves the issue...
That's a pity though, now the users will have to click whereas they didn't have to if it were contained in the text field. Any idea?
Thank you
Copy link to clipboard
Copied
I am trying to do something somewhat similar, but when you get the second drop down menu and make a selection, I would like a set of questions to populate on the next page that correlates to the answer chosen in the drop down menu. Hope that makes sense?
For example, First drop down menu you select FCBC and then the sub menu could populate PT, Dentist, Ambulance, etc, etc, and when the PT selection was chose you would get a populated set of PT questions on the next page, or if Dentist was chosen, then dentist questions, etc, etc.
Copy link to clipboard
Copied
It's possible, but both things will work independently of each other. You will have one script to populate the second drop-down with options dependent on the selection in the first, and another to populate or show/hide the question fields based on the selection in the second drop-down field.
Copy link to clipboard
Copied
Do you happen to know how to write the script?
Copy link to clipboard
Copied
Yes, I've developed similar scripts for my clients in the past. If you're interested in hiring someone to do it for you feel free to contact me privately (try6767 at gmail.com).
Copy link to clipboard
Copied
Hello,
I have tried to follow the code and just rename the fields in my doc, but i am missing some pieces.
I have a main Field menu "Provider" and if i choose the option "5 - Hospital" want to be able to choose between different hospitals from second menu "Hospital", where i have like 12 different hospitals.
If i choose other option the 5 - Hospital, i dont want the workers to see that second menu with hospitals in it.
This is the code i have tried:
switch (event.value) {
case "5 - Hospital":
this.getField("Hospital").setItems(["-","35600","35601","35602"]);
break;
}
Even if i choose option 3 -Customer for example, i can still see the fields with hospitals in it.
Is there an easy fix for this? It should be really easy but somehow i cant crack it.
Enclosing picture of that as well
Thank you
Copy link to clipboard
Copied
You can show/hide the field "Hospital".
Copy link to clipboard
Copied
Would this code be correct for that?
case "1 - Customer":
this.getField("Hospital").display=display.hidden
break;
case "2 - Shop":
this.getField("Hospital").display=display.hidden
break;
Somehow it hides the field Hospital completely and i cant see it anymore. Im sorry im a dummie and i ve been looking all over tutorials for last 2 hours but still didnt manage
Copy link to clipboard
Copied
You must add also:
case "5 - Hospital":
this.getField("Hospital").display = display.visible;
this.getField("Hospital").setItems(["-","35600","35601","35602"]);
break;