Copy link to clipboard
Copied
I am trying to create an order form in Acrobat Pro.
I need a drop down box with three choices, I have placed four choices with two spaces being the default choice. I have given all four choices export values of 0, 1, 2, and 3 respective of how they appear as choices in the drop down box. I am trying to populate a text box directly under the drop down box with instructions based on which choice is picked in the drop down box. I have chosen Commit selected value immediately for the Option in the drop down box. I am a bit confused under the Add an Action portion. Do I want mouse Up, Down, Enter, Exit....
I have it set now for Mouse Enter and Run a JavaScript
and here is my code:
(function () {
if (!event.willCommit) {
// Set up an array of options. \r = carriage return
var aInst = [];
aInst[0] = "";
aInst[1] = "Starting Dose (Weeks 1-12) \rInstructions: \rStep 1: INJECT 0.25mg (0.05mls OR 5u on syringe) SQ ONCE A WEEK FOR 4 WEEKS. \rStep 2: INJECT 0.5mg (0.1mls OR 10u on syringe) SQ ONCE A WEEK FOR 4 WEEKS. \rStep 3: INJECT 1mg (0.2mls OR 20u on syringe) SQ ONCE A WEEK FOR 4 WEEKS.";
aInst[2] = "Second Dose (Weeks 13-17) \rInstructions:\rStep 1: INJECT 1.7mg (0.35mls OR 35u on syringe) SQ ONCE A WEEK FOR 4 WEEKS.\rStep 2: INJECT 2.4mg (0.5mls OR 50u on syringe) SQ ONCE WEEKLY THEREAFTER.";
aInst[3] = "Maintenance Dose (1 Month)\rInstructions:\rStep 1: INJECT 2.4mg (0.5mls OR 50u on syringe) SQ ONCE WEEKLY THEREAFTER.";
var ex_val = event.changeEx;
var tt = aInst[ex_val];
getField("TT").value = tt;
}
})();
The text box keeps coming up as undefined. Any help would be greatly appreciated, I have the distinct feeling it is something simple this non coder is missing. I am not getting errors in the script editor, but it is not operating as I am hoping.
Copy link to clipboard
Copied
Thank you for taking time to respond to me. I do have it in as a Keystroke script for my drop down box. But for some reason the text box TT shows "undefined" regardless of what is chosen in the drop down box. I was surprised I coudn't get it to work. While not a programmer, I am fairly savvy. I managed to mangle an active directory domain controller out of an old Ubunut box this last week and play with MQTT at home with Home Assistant without issue. Which really just means I understand enough to be dangerous and follow directions.
Copy link to clipboard
Copied
This code should be used as the dropdown field's custom Keystroke script. It will probably "disappear" after you add it due to a bug in Acrobat, but should still work. It does for me.
Copy link to clipboard
Copied
Thank you for taking time to respond to me. I do have it in as a Keystroke script for my drop down box. But for some reason the text box TT shows "undefined" regardless of what is chosen in the drop down box. I was surprised I coudn't get it to work. While not a programmer, I am fairly savvy. I managed to mangle an active directory domain controller out of an old Ubunut box this last week and play with MQTT at home with Home Assistant without issue. Which really just means I understand enough to be dangerous and follow directions.
Copy link to clipboard
Copied
The script should work fine as 'Custom keystroke script', the only 'undefined' is when you add choices after you added script, but even then when start to change choices it should work fine.
You can try this as 'Custom calculation script':
if(event.value == 0)
this.getField("TT").value = "";
else if(event.value == 1)
this.getField("TT").value = "Starting Dose (Weeks 1-12) \rInstructions: \rStep 1: INJECT 0.25mg (0.05mls OR 5u on syringe) SQ ONCE A WEEK FOR 4 WEEKS. \rStep 2: INJECT 0.5mg (0.1mls OR 10u on syringe) SQ ONCE A WEEK FOR 4 WEEKS. \rStep 3: INJECT 1mg (0.2mls OR 20u on syringe) SQ ONCE A WEEK FOR 4 WEEKS.";
else if(event.value == 2)
this.getField("TT").value = "Second Dose (Weeks 13-17) \rInstructions:\rStep 1: INJECT 1.7mg (0.35mls OR 35u on syringe) SQ ONCE A WEEK FOR 4 WEEKS.\rStep 2: INJECT 2.4mg (0.5mls OR 50u on syringe) SQ ONCE WEEKLY THEREAFTER.";
else if(event.value == 3)
this.getField("TT").value = "Maintenance Dose (1 Month)\rInstructions:\rStep 1: INJECT 2.4mg (0.5mls OR 50u on syringe) SQ ONCE WEEKLY THEREAFTER.";
Copy link to clipboard
Copied
The result you're getting means no value in the data-model matched the value of the drop-down.
Are you sure you entered them correctly? Did you use export values, by any chance?
It would be easier to help you if you shared the actual file with us.
Copy link to clipboard
Copied
I did use export values.
The solution of using a Custom Calculation Script worked exactly as I was trying to make the keystroke script work, so I moved on.
I was unaware of including the file. Many moons ago, when I played more in this kind of thing, uploading the entire file was frowned on.
Thank you for all the replies.