Unchecked an option in a checkbox when another option is checked

Unchecked an option in a checkbox when another option is checked

Hi, in a Creator form, I have around twenty checkbox fields, named for example "cb1", "cb2", "cb3", etc...

Each of these fields have two options: Done and N/A.

I would like to be able to for each field, if I check "Done", "N/A" is unchecked, and if I check "N/A", "Done" is unchecked. And if I uncheck both, it remains unchecked.

I don't want to repeat the code for all 20 fields, I assume there is a solution to get all the fields, or list them, and then loop, but everything I try doesn't work.

If you have an example to offer me, that would help me a lot, thank you.

Exemple :
  1. checkBoxFields = {"cb1", "cb2", "cb3", "cb4", "cb5"};

  2. for each cbField in checkBoxFields
  3. {
  4.     fieldValue = cbField.values();
  5. info fieldValue ;

  6.     if (fieldValue.contains("Fait"))
  7.     {
  8.         fieldValue.remove("N/A");
  9.         input.set(cbField, fieldValue);
  10.     }
  11.     else if (fieldValue.contains("N/A"))
  12.     {
  13.         // Décocher "Fait"
  14.         fieldValue.remove("Fait");
  15.         input.set(cbField, fieldValue);
  16.     }
  17. }