Copy link to clipboard
Copied
I would appreciate any assistance regarding several questions I have about scripting for a particular form. I am NOT a coder (so please type slowly!). I am currently using Acrobat Pro 11.0.23 on Windows 10.
Below is a screen shot of the planned form:
INFORMATION ABOUT THE FORM:
THANK YOU to anyone who could give me some help/advice on this.
It seems fine... Are you seeing any error messages in the JS Console (Ctrl+J)? Are there no results at all, or are they incorrect?
If the latter, check the field calculation order.
Also, do not edit the code in the Edit All JavaScripts window. It's a recipe for problems. Only edit it under the field or the doc-level script.
Copy link to clipboard
Copied
1. Use check-boxes. Make sure to name them in a consistent manner and give them proper export values. It will help later on.
2. This will require a custom-made calculation script. Should it work for each row? Each category (Minimal/Low/Moderate/High)? Something else?
3. Again, this will require a script. It can use the results from the Yes/No fields, though.
Copy link to clipboard
Copied
Let's say you named the check-box fields "Problem1", "Problem2", "Procedure1", "Procedure2", "Option1", "Option2", etc.
You can enter this function as a doc-level script (under Tools - JavaScript - Document JavaScripts):
function checkFields(fields) {
for (var i in fields) {
var f = this.getField(fields);
if (f.valueAsString!="Off") return "YES";
}
return "NO";
}
Then, create text fields called "Minimal Level", "Moderate Level", etc., and put the following as the custom calculation script of the Minimal one:
event.value = checkFields(["Problem1", "Problem2", "Procedure1", "Procedure2", "Option1", "Option2"]);
Repeat the same for the other levels, with the correct field names.
For the "Final Level" text field you can then use the following, again as the custom calculation script:
if (this.getField("High Level").valueAsSting=="YES") event.value = "HIGH";
else if (this.getField("Moderate Level").valueAsSting=="YES") event.value = "MODERATE";
else if (this.getField("Low Level").valueAsSting=="YES") event.value = "LOW";
else if (this.getField("Minimal Level").valueAsSting=="YES") event.value = "MINIMAL";
else event.value = "";
Copy link to clipboard
Copied
TRY67 -
Thank you so much! I'm pretty decent with copy and paste and your answer was great.
For some reason, I am not able to get the "FINALLEVEL" Text Box to populate with anything.
Everything else seems to work fine.
Here is a screen shot of the first-pass draft. As you can see - a CHECK in any of the boxes converts the YES/NO to YES. (PERFECT!)
But, there is nothing in the FINAL LEVEL box.
This is the script from the FinalLevel Text Box:
Below is the entire script
//-------------------------------------------------------------
//-----------------Do not edit the XML tags--------------------
//-------------------------------------------------------------
//<Document-Level>
//<ACRO_source>EVALUATION</ACRO_source>
//<ACRO_script>
/*********** belongs to: Document-Level:EVALUATION ***********/
function checkFields(fields) {
for (var i in fields) {
var f = this.getField(fields);
if (f.valueAsString!="Off") return "YES";
}
return "NO";
}
//</ACRO_script>
//</Document-Level>
//<AcroForm>
//<ACRO_source>FINALLEVEL:Calculate</ACRO_source>
//<ACRO_script>
/*********** belongs to: AcroForm:FINALLEVEL:Calculate ***********/
if (this.getField("HighLevel").valueAsSting=="YES") event.value = "HIGH";
else if (this.getField("ModerateLevel").valueAsSting=="YES") event.value = "MODERATE";
else if (this.getField("LowLevel").valueAsSting=="YES") event.value = "LOW";
else if (this.getField("MinimalLevel").valueAsSting=="YES") event.value = "MINIMAL";
else event.value = "";
//</ACRO_script>
//</AcroForm>
//<AcroForm>
//<ACRO_source>HighLevel:Calculate</ACRO_source>
//<ACRO_script>
/*********** belongs to: AcroForm:HighLevel:Calculate ***********/
event.value = checkFields(["Prob010", "Proc010", "Opt010"]);
//</ACRO_script>
//</AcroForm>
//<AcroForm>
//<ACRO_source>LowLevel:Calculate</ACRO_source>
//<ACRO_script>
/*********** belongs to: AcroForm:LowLevel:Calculate ***********/
event.value = checkFields(["Prob3", "Proc3", "Opt3"]);
//</ACRO_script>
//</AcroForm>
//<AcroForm>
//<ACRO_source>MinimalLevel:Calculate</ACRO_source>
//<ACRO_script>
/*********** belongs to: AcroForm:MinimalLevel:Calculate ***********/
event.value = checkFields(["Prob1", "Proc1", "Opt1"]);
//</ACRO_script>
//</AcroForm>
//<AcroForm>
//<ACRO_source>ModerateLevel:Calculate</ACRO_source>
//<ACRO_script>
/*********** belongs to: AcroForm:ModerateLevel:Calculate ***********/
event.value = checkFields(["Prob7", "Proc7", "Opt7"]);
//</ACRO_script>
//</AcroForm>
Copy link to clipboard
Copied
It seems fine... Are you seeing any error messages in the JS Console (Ctrl+J)? Are there no results at all, or are they incorrect?
If the latter, check the field calculation order.
Also, do not edit the code in the Edit All JavaScripts window. It's a recipe for problems. Only edit it under the field or the doc-level script.
Copy link to clipboard
Copied
Perfect.
Got it working. Thanks again!