Copy link to clipboard
Copied
I have a mass update that I'm trying to avoid having to do manually.
Is it possible to push an action onto an existing field?
Specifically;
loop for all fields {
if (discriminate for fields I want){
update fields 'mouse up' action to 'run JS' (I have set it up that
they can all use the same code).
}
}
Copy link to clipboard
Copied
Use the method setAction.
Copy link to clipboard
Copied
for (var i = 0; i < this.numFields; i++) {
var oFld = this.getField(this.getNthFieldName(i));
if (oFld.type == "text") {
oFld.setAction("MouseUp", "run-JS();");
}
}
Acrobate du PDF, InDesigner et Photoshoptographe
Copy link to clipboard
Copied
Use the method setAction.
Copy link to clipboard
Copied
for (var i = 0; i < this.numFields; i++) {
var oFld = this.getField(this.getNthFieldName(i));
if (oFld.type == "text") {
oFld.setAction("MouseUp", "run-JS();");
}
}
Acrobate du PDF, InDesigner et Photoshoptographe
Copy link to clipboard
Copied
Thank you both!
I'd found setAction in the documentation but not run-JS(). I was worried that I was in for a good 4+ hours of manual copy-pasting there. :S
Copy link to clipboard
Copied
Use a document level function. When you must change the script you must only change the function.
Copy link to clipboard
Copied
Yeah, the code body is all in doc level functions. What I specifically needed was to allow all fields of a specific type (that I can discriminate for by naming convention) to call a function when clicked. The code that I was inserting was just:
buildingClicked(event.target.name);
With 'buildingClicked' being an alternate entry to the main code. The 'main' method of input until this was 2 dropdowns, where input values were taken from the values of those boxes. This update allows users to click a box directly and input the other value via a popup.
Problem was, there are ~200 fields I wanted to add this too, so doing it manually was not really gonna happen!
Sometimes I find the ref docs really useful, other times almost misleading, so really appreciate the help clarifying, thank you. 🙂
Copy link to clipboard
Copied
It was you who put "run-JS" in your request, I thought it was a function that you had create.
Jut remove "run-JS" and replace it with your script.
Acrobate du PDF, InDesigner et Photoshoptographe
Copy link to clipboard
Copied
Oh I see now. Thanks, that's actually making sense with the documentation now. A roundabout way but I got there!
Copy link to clipboard
Copied
ugh, can't edit but yes, sorry I kinda had that in the original post. I meant it in simplified English terms, rather than literal though.

