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

Code to check and uncheck checkbox

New Here ,
Nov 16, 2016 Nov 16, 2016

Good Morning everyone

I am creating a form with many check box and I have two button one is NONE and the other one is ALL

I would like to be able to Uncheck all check box if I click NONE and I would like to be able to check all

check box if I click ALL

and I tought I had to use javascript code to be able to do that on both buttons ( NONE and ALL )

but I have try different code and didn't work

2016-11-16 8-12-17 AM.png

TOPICS
PDF forms
3.5K
Translate
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
LEGEND ,
Nov 16, 2016 Nov 16, 2016
LATEST

You do but it is not just one statement. Depending upon how you have named your check boxes and what value you have assigned to them when checked will need to be used to check or uncheck the check boxes. An unchecked check box field has a value of "Off".

What code have you tried?

The custom JavaScript code will depend upon how you have named the fields and what value you have assigned to the "Checked Value".

The easiest would be to use hierarchical field names and all field have the same checked value.

// using hierarchical field names;

// check all;

// field names are "Check Box.#";
// get the parent field object;
var oAll = this.getField("Check Box");
// create an array of individual field objects;
var aAll = oAll.getArray();
// set each dhild field's value to "Yes";
for(var i = 0; i < aAll.length; i++)
{
aAll.value = "Yes";
}

You would uncheck them by setting the value to "Off".

The code get more complex if you use individual and different names for each field or assign different values for the "Checked Value".

Translate
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