• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Can I change the color 1 checkbox from a group of mutually exclusive checkboxes with 0-based index ?

Community Expert ,
Aug 10, 2020 Aug 10, 2020

Copy link to clipboard

Copied

How can I access the 0-based index of an individual radio button or check box widget for a field that belongs to a mutually exclusive group of checkboxes?

 

All the SDK documentation that I've read doesn't  illustrate with a clear example of how to work around this if you use .fillColor  or  readonly .

 

Can anyone confirm if this is a field versus widget attributes issue?

 

In the script below, the condition works perfectly when I use the  checkThisBox parameter, for example.

 

However, I can't figure out how to achieve the same results with fillColor and readonly.

 

Here's my script example:

 

 

//I hve three mutually exclusive checboxes acting like radio buttons
//each checkbox has export values assigned like "myCheckbox 0", "myCheckbox 1", "myCheckbox 2"

// var g is a dropdown depending on what is selected the conditions below should be met

var g = event.value;
var f =  this.getField("myCheckbox");

if ((g =="True") || (g =="False") || (g =="Don't Know"))  {

f.checkThisBox(2, true); 
f.readonly =  true;
f.fillColor = color.red


}  else {


f.checkThisBox(2, false);
f.readonly = false;
f.fillColor = color.transparent


}

 

 

So basically I was looking for  if there's something that should be called like this:

 

f[2].fillColor = color.red;

f.fillColor(2) = color.red; 

 

In the form that I am working on I can't have all those other widgets turn red, just the checkbox that gets checked from the condition that is met when the user selcts certain listed items from the pulldown menu.

 

What am I missing?

 

Where can I find the appropriate documentation to achieve this? 

TOPICS
Acrobat SDK and JavaScript

Views

412

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

Community Expert , Aug 10, 2020 Aug 10, 2020

I just found the answer for the fillColor.

 

The appropriate reference is in the Acrobat SDK, Developing Acrobat Applications Using JavaScript guide.

 

For anyone who has the same question look in  Page 81  "Setting Acrobat form field properties"   specifically in the "Radio button fields" section Example 6.3 - Accessing individual radio button widgets

 

In the script below, this line this.getField(f.name+".2").fillColor = ["G",0.7];   resolves this issue for the color. I am still looking for the read

...

Votes

Translate

Translate
Community Expert ,
Aug 10, 2020 Aug 10, 2020

Copy link to clipboard

Copied

LATEST

I just found the answer for the fillColor.

 

The appropriate reference is in the Acrobat SDK, Developing Acrobat Applications Using JavaScript guide.

 

For anyone who has the same question look in  Page 81  "Setting Acrobat form field properties"   specifically in the "Radio button fields" section Example 6.3 - Accessing individual radio button widgets

 

In the script below, this line this.getField(f.name+".2").fillColor = ["G",0.7];   resolves this issue for the color. I am still looking for the readonly attribute.

 

var g = event.value;
var f =  this.getField("testwithCB");
var f1 = this.getField(f.name+".2");
if ((g =="A") || (g =="B") || (g =="C"))  {

f.checkThisBox(2, true); 
this.getField(f.name+".2").fillColor =  ["G",0.7]; 


}  else {


f.checkThisBox(2, false);
f.readonly = false;
f.fillColor = ["RGB",0.874,0.874,1];


}

 

 

Votes

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