Copy link to clipboard
Copied
Hello Community, as you may already see I have no Tech knowledge, but using AI was able to have some what of a code that works.
"
if ((event.source.forReal) && (event.source.stampName == "#QAStamp")) {
// Define the messages for each check box
var messages = [
"NIST Traceable:",
"Lab ID:",
"Calibration Standard:",
"Calibration Status/Re-calibration Date:",
"Actual Results:",
"Notes of Adjustment:",
"Parker Tolerance Used:",
"Parker Tolerance Stated:"
];
// Loop through each check box and prompt the user to check or uncheck
for (var i = 1; i <= 8; i++) {
var checkBoxValue = app.response({
cQuestion: messages[i - 1] + " (Yes/No):",
cTitle: "Check Box Selection",
cDefault: "No"
});
this.getField("Check Box" + i).value = (checkBoxValue.toLowerCase() === "yes") ? "Yes" : "Off";
}
// Prompt user for initials
this.getField("Initials").value = app.response("Initials: ");
}"
but I do not like the behavior, since if you run it you can see the dialogue boxes appear individually and the user has to write "YES" every time.
I try having it modify, but it does not run, I gave the permits and all, but it is my work PC
"if ((event.source.forReal) && (event.source.stampName == "#QAStamp")) {
// Create a custom dialog box
var theDialog = {
initialize: function(dialog) {
dialog.load({
"Check Box1": "Off",
"Check Box2": "Off",
"Check Box3": "Off",
"Check Box4": "Off",
"Check Box5": "Off",
"Check Box6": "Off",
"Check Box7": "Off",
"Check Box8": "Off",
"Initials": "",
"Date": util.printd("mm/dd/yyyy", new Date())
});
},
commit: function(dialog) {
var data = dialog.store();
for (var i = 1; i <= 8; i++) {
event.target.getField("Check Box" + i).value = data["Check Box" + i];
}
event.target.getField("Initials").value = data.Initials;
event.target.getField("Date_af_date").value = data.Date;
},
description: {
name: "Check Box Selection",
elements: [
{ type: "checkbox", item_id: "Check Box1", name: "NIST Traceable" },
{ type: "checkbox", item_id: "Check Box2", name: "Lab ID" },
{ type: "checkbox", item_id: "Check Box3", name: "Calibration Standard" },
{ type: "checkbox", item_id: "Check Box4", name: "Calibration Status/Re-calibration Date" },
{ type: "checkbox", item_id: "Check Box5", name: "Actual Results" },
{ type: "checkbox", item_id: "Check Box6", name: "Notes of Adjustment" },
{ type: "checkbox", item_id: "Check Box7", name: "Parker Tolerance Used" },
{ type: "checkbox", item_id: "Check Box8", name: "Parker Tolerance Stated" },
{ type: "static_text", item_id: "spacer", name: "ENGINEERING YOUR SUCCESS" },
{ type: "edit_text", item_id: "Initials", name: "Initials" },
{ type: "edit_text", item_id: "Date", name: "Date" },
{ type: "ok_cancel_group" }
]
}
};
// Display the dialog box
var result = app.execDialog(theDialog);
if (result === "ok") {
theDialog.commit.call(this, theDialog);
}
}"
Copy link to clipboard
Copied
So first, when you post code it is assumed you would like someone else to make sense of it so you can get some help. To this end it is helpful to the rest of us if the code is formatted in such a way that it is easy to read. This is especially true for complicated code.
But, from a quick read, there are a few of things about the dialog box code that are problematic. For example, fields on a dialog are very different from fields on a PDF. You can't name them the same way or set value in the same way. The code above is a mess. You need to either spend some time learning about JavaScript and the Acrobat Model, or hire someone.
If you are interested in leaning about how to do this right I'd suggest starting by using this tool.
https://www.pdfscripting.com/public/ACRODIALOGS-OVERVIEW.cfm
Copy link to clipboard
Copied
Thank you Tom!
Copy link to clipboard
Copied
[MOVED TO THE ACROBAT DISCUSSIONS]
Find more inspiration, events, and resources on the new Adobe Community
Explore Now