Skip to main content
Inspiring
December 30, 2024
Answered

add script

  • December 30, 2024
  • 2 replies
  • 374 views

I have a lot of checkboxes, I want to add on focus script to all the checkboxes, is there a way to automate this?

This topic has been closed for replies.
Correct answer Nesa Nurani

You can use this in a button or run from console:

for(var i=0; i<this.numFields; i++){
var fname = this.getNthFieldName(i);
var f = this.getField(fname);
if(f==null) continue;
if(f.type=="checkbox") f.setAction("OnFocus", "Put your script here");}

In your script, use single quotes or escape quotes with backslash.

2 replies

Nesa Nurani
Community Expert
Nesa NuraniCommunity ExpertCorrect answer
Community Expert
December 30, 2024

You can use this in a button or run from console:

for(var i=0; i<this.numFields; i++){
var fname = this.getNthFieldName(i);
var f = this.getField(fname);
if(f==null) continue;
if(f.type=="checkbox") f.setAction("OnFocus", "Put your script here");}

In your script, use single quotes or escape quotes with backslash.

PDF Automation Station
Community Expert
Community Expert
December 30, 2024

Nice work!