Check Box = a value but only one box in a group can be checked

New Here ,
Jun 16, 2022 Jun 16, 2022

Copy link to clipboard

Copied

Checkboxes - Exceed2, Exceed5, Exceed6

Text Fields - Exceed Count 2, Exceed Count 5, Exceed Count 6

 

I have a column for an employee performance documents with 3 rows of items (Exceed2, Exceed5, Exceed6).  Each row has a checkbox, that if it is checked it will give the corresponding textbox beside it a value of 2.  If unchecked it will be blank.  I have gotten this to work using the custom calculation script.  This is the formula I used.

 

if (this.getField("Exceed2").isBoxChecked(0))
event.value = 2;
else
event.value = "";

 

 

My issue is I only want one of the checkboxes to be able to be checked at a time.  Is this possible?  If not, is it with radio buttons?  

TOPICS
Acrobat SDK and JavaScript

Views

63

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
Adobe Community Professional ,
Jun 17, 2022 Jun 17, 2022

Copy link to clipboard

Copied

It's possible, give all 3 checkboxes same name but give them different export value.

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
Adobe Community Professional ,
Jun 17, 2022 Jun 17, 2022

Copy link to clipboard

Copied

Read this primer on Checkboxes/radiobuttons in Acrobat:

https://www.pdfscripting.com/public/Checkboxes-and-Radio-Buttons.cfm

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

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
Adobe Community Professional ,
Jul 03, 2022 Jul 03, 2022

Copy link to clipboard

Copied

LATEST

++ Adding to the discussion

 

In this scenario, if you want to be able to check one at a time, I would preffer better to use mutually exclusive radio buttons but with the same export value of "2" on each one, and then employ an action script for each of the radio button that corresponds to the desired Exceed2, Exceed5, Exceed6 text fields respectively.

 

 

I would add a script to each radio button as shown below:

// script for the radio butron next to Exceed2 field

if (event.target.value=="Off"){

this.getField("Exceed2").value ="";

} else {

this.getField("Exceed2").value = event.target.value;

this.getField("Exceed5").value = "";

this.getField("Exceed6").value = "";

}

 

 

 

 

 

 

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