These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Mark several form fields

llong70
Registered: Nov 29 2010
Posts: 4
Answered

I have created a form which contains many checkboxes (box1, box2, box3).
I also make a button that if endusers click on then all the boxes are marked and put a value (Cross) in the box.
 
Endusers can also choose that thay can check the boxes one by one.
 
I can't make it happened. I nned a script that do a such thing. Could you help med with that?
      

My Product Information:
Acrobat Pro Extended 9.3, Windows
try67
Expert
Registered: Oct 30 2008
Posts: 2398
(From the reference file)

Check a check box:

// check the box "ChkBox"
var f = this.getField("ChkBox");
f.checkThisBox(0,true);

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
There are 2 ways you can do this. You can set the value of the check box to the 'exportValue' of the box or use the 'checkThisBox()' metohd.

// define an array of the check boxes to check
var aCheckBoxes = new Array('box1', 'box2', 'box3');
// do not change the code below this line
( function() {
// field object
var oField;
// loop trough fields
for(i in aCheckBoxes) {
// get a check box
oField = this.getField(aCheckBoxes[i]);
// force it to be checked
oField.checkThisBoxmethod(0, true);
}
return;
}) ();

More information is available in the Acrobat JavaScript API Reference.

George Kaiser

llong70
Registered: Nov 29 2010
Posts: 4
Thank You for the solution, but the script does not work.
I copied the script into my pdf,
- where I create a button
- in Action fan I choose Run a JavaScript
- I copy the script into the field
- make some changes
- run the script

But nothing happens.

What am I doing wrong?


try67
Expert
Registered: Oct 30 2008
Posts: 2398
How are we supposed to know what you're doing wrong if you don't provide any actual information?
What did you change? What do you see in the console? etc.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

llong70
Registered: Nov 29 2010
Posts: 4
gkaiseril wrote:
There are 2 ways you can do this. You can set the value of the check box to the 'exportValue' of the box or use the 'checkThisBox()' metohd.// define an array of the check boxes to check
var aCheckBoxes = new Array('box1', 'box2', 'box3');
// do not change the code below this line
( function() {
// field object
var oField;
// loop trough fields
for(i in aCheckBoxes) {
// get a check box
oField = this.getField(aCheckBoxes[i]);
// force it to be checked
oField.checkThisBoxmethod(0, true);
}
return;
}) ();

More information is available in the Acrobat JavaScript API Reference.
I used this script an the only thing I change was this line:
var aCheckBoxes = new Array('box1', 'box2', 'box3');

I also tried the s from cript try67. It does not work either

George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1875
Accepted Answer
That script has a typo (checkThisBoxmethod) in it. Try this:

(function () {

// Create an array of check box names
var aCheckBoxes = ["box1", "box2", "box3"];
var oField;

// Loop through fields
for (var i in aCheckBoxes) {

// Get a check box
oField = getField(aCheckBoxes[i]);

// Force it to be checked
oField.checkThisBox(0, true);
}

})();

You will have to replace "box1", "box2", "box3" in the code above with the actual names of the check boxes you want to control. Add as many check box names to the array as you need. This code assumes that if you have more than one check box with the same name, that they also have the same export value.
llong70
Registered: Nov 29 2010
Posts: 4
Thank you George_Johnson
The script works fine. My Christmas is saved