Expand my Community achievements bar.

How to work with several checkboxes ?

Avatar

Level 9

Hello All,

I have a form which contain several pages. Out of those one page has nearly 40 checkboxes. If any one of those checkboxes are checked then the readonly checkbox which corresponds to these checkboxes should be checked. All the checkboxes have different field names. How to do it in the best simplified manner. is it possible to use function here ? If yes , how to do it ?

Thanks.

Bibhu.

8 Replies

Avatar

Level 10

Hi Bibhu,

I would set the object name for the open checkbox and the corresponding readOnly checkbox to be the same name. Then set the binding to 'Global Binding' in the Object > Binding tab.

This way when the user ticks the open checkbox, the readonly checkbox will also be ticked. No scripting required.

Good luck,

Niall

Avatar

Level 9

Hello Niall,

Thanks for the reply . But the client has fixed naming of the fields. I am not allowed to change any field names. So in that case how to do it ?

Thanks.

Bibhu.

Avatar

Level 10

Hi,

In that case you will need script. If the object names are fixed it probably doesn't make sense to use a function. So will would need script in the click event of the 40 checkboxes, to change the value of the readOnly checkboxes. For example:

if (this.rawValue === 1)

{

     page7.checkbox36.rawValue = "1";

}

else

{

     page7.checkbox36.rawValue = "0";

}

Hope that helps,

Niall

Avatar

Level 9

Hello Niall,

I guess use of this script might create a problem. Suppose I click checkbox -1 then the readonly check box is checked. After that I clicked the checkbox 2. After that I again click the checkbox -1 so , as the vale of the checkbox-1 is 0 now , it will make the readonly checkbox un checked. But at the same time the checkbox - 2 is checked which violates the condition (if any one check box is checked then the readonly check box becomes checked). How to get it over with . Do I need to put a condition which checks the value of all checkboxes before clicking any checkbox ? But will not it be cumbersome ?

Thanks.

Bibhu.

Avatar

Level 10

Hi,

The example I set out was for a simple / single test. If the business logic is more complex, then you will have to build your if statements to suit. Just remember to separate tests with && (and) or || (or) in JavaScript.

Maybe have the script in the calculate event of the readOnly checkboxes, looking back at the values of the relevant checkboxes from the 40 options.

Without seeing the form it is difficult to be more specific.

Good luck,

Niall

Avatar

Level 9

Hello Niall,

I was just thinking about to rename those check boxes and use function.My requirements are as follows . I need your help in doing the same.

- In Page -1 I have got 2 readonly check boxes say ReadOnly_1 , ReadOnly_2 .

- In Page - 4 I have 20 check boxes say , OptionA_1 to OptionA_20.

- In Page - 5 I have 40 Checkboxes , say OptionB_1 to OptionB_20.

  The ReadOnly_1 and ReadOnly_2 checkboxes present in page -1 get autochecked if any checkboxes in page -4 or Page - 5 is checked.The problem is we have to check the condition for all the checkboxes , whether they are selected or not . How to implement this using a function . As I am an amateur in using function . Is there any better approach to rename those checkboxes so that I will not have any difficulty in making script changes. Few of the checkboxes already have few codes which are needed. How to do this in best possible manner ?

Thanks.

Bibhu.

Avatar

Level 10

Hi Bibhu,

I would use a hidden field on each of the pages to keep track of the checkboxes ticked on their respective pages (scores). Then in the calculate event of the readOnly checkboxes on page1 I would have a simple if statement, looking at the scores.

Here is another example: https://acrobat.com/#d=onheZFBKvcuWg*9xyBn-Zg

Hope that helps,

Niall

Avatar

Level 9

Hello Niall,

Thanks for the form . But before receiving this form I have put conditions in the if statement for all those check boxes across the page (Heck !!! It was 80). Then I called the click event in each checkbox. I am so fool .

Thanks.

Bibhu.