Copy link to clipboard
Copied
Hi I was just wondering if someone was able to give me a hand with some javascript, I have a form with a variety of check boxes all with different export values which is used for another scripting function. I would like a button to check/uncheck specific boxes.
Example:
var MyVar="box1", "check7", "Sample2";
if(this.getField("MyVar").isChecked()); {
this.getField("myVar).checked(0,false)
} else {
this.getField("myVar).checked(0,true)
app.alert("Your default boxes have been checked.",0);
}
Thanks in advance for your help
Try like this:
var MyVar = ["box1", "check7", "Sample2"];
var total = 0;
for (var i in MyVar){
if(this.getField(MyVar[i]).isBoxChecked(0))
this.getField(MyVar[i]).checkThisBox(0,false);
else{
this.getField(MyVar[i]).checkThisBox(0,true);
if(this.getField(MyVar[i]).isBoxChecked(0))total++;
if(total == 3)
app.alert("Your default boxes have been checked.",0);}}
Will all 3 checkboxes always be at same state? Because if some are checked and others unchecked script won't work as intended.
Copy link to clipboard
Copied
Try like this:
var MyVar = ["box1", "check7", "Sample2"];
var total = 0;
for (var i in MyVar){
if(this.getField(MyVar[i]).isBoxChecked(0))
this.getField(MyVar[i]).checkThisBox(0,false);
else{
this.getField(MyVar[i]).checkThisBox(0,true);
if(this.getField(MyVar[i]).isBoxChecked(0))total++;
if(total == 3)
app.alert("Your default boxes have been checked.",0);}}
Will all 3 checkboxes always be at same state? Because if some are checked and others unchecked script won't work as intended.
Copy link to clipboard
Copied
Thanks Nesa, worked like a charm! 8)👍