Skip to main content
deckarduk
Inspiring
August 1, 2022
Question

Query re check box groups, help required please...

  • August 1, 2022
  • 1 reply
  • 1847 views

Hi there,

 

Just a quick question regarding checkbox groups.

 

I have a group of checkboxes and they're all named the same - xyz.

I can reference each checkbox as below:

var w = this.getField("xyz.0")
w.checkThisBox(0,true);

Using the index xyx.0, xyz.1, xyz.2 etc I can reference each checkbox individually.

 

Is there a way to get the number of checkboxes, or widgets, in the group?

I've tried a couple of things, such as w.length and w.count, but as yet haven't succeeded.

Obviously when trying to reference the group I'm using var w = this.getField("xyz"), there is no index as the code above.

 

Thanks in advance.

This topic has been closed for replies.

1 reply

try67
Community Expert
Community Expert
August 1, 2022

You can do it using the exportValues or page properties. Both will return an array, and the length of that array is the number of "widgets" in the group.

 

PS. The first parameter of checkThisBox is the index number of the box to check, so instead of doing it like this:

var w = this.getField("xyz.0")
w.checkThisBox(0,true);

You can just use:

this.getField("xyz").checkThisBox(0,true);

deckarduk
deckardukAuthor
Inspiring
August 1, 2022

Hi Gilad,

Thanks for the help, much appreciated 👍

Thanks also for the PS coding tip 🙂

Cheers!

try67
Community Expert
Community Expert
August 1, 2022

Just one small clarification, if there's only one widget the page property will return a number, not an array.

The exportValues property always returns an array, but it can only be used for check-boxes and radio-buttons, while page is available for any type of field.