Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


Mouseup event to toggle check boxes

New Here ,
Aug 29, 2021 Aug 29, 2021

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

TOPICS
JavaScript, PDF forms

Views

43

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Adobe Community Professional , Aug 29, 2021 Aug 29, 2021
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.

Likes

Translate

Translate
Adobe Community Professional ,
Aug 29, 2021 Aug 29, 2021

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.

 

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 30, 2021 Aug 30, 2021

Copy link to clipboard

Copied

LATEST

Thanks Nesa, worked like a charm! 8)👍

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines