Skip to main content
Participant
Nov 2, 2026 8:04 PM UTC
Answered

dropdown selection auto-selecting checkboxes

I hope someone can help as I’ve tried to follow other comments regarding checkboxes automatically being checked when selecting a dropdown choice and am getting no where.

I have a dropdown box with 4 lab group choices (HDRL, RAD, LDL, (blank = space bar).  

The blank choice is just there to force users to select lab otherwise the lab group stays blank. 

I then have checkboxes for all the labs that are associated with each lab group.  The checkboxes fields are named “cb1” for lab 1, “cb2” for lab2, “cb3” for lab3

How do I get:

  • Checkboxes cb1 - cb3 to only be checked when selecting HDRL in the drop down
  • Checkboxes cb4 - cb6 to only be checked when selecting RAD in the drop down
  • Checkboxes cb7 - cb9 to only be checked when selecting LDL in the drop down
  • When the lab choice is blank I’d like no boxes to be automatically check.

TIA

    Anand Sri Bhattacharya
    Community Manager
    Nov 4, 2026 9:52 AM UTC

    Hello ​@Malcolm28876973cmri 

     

    Thanks for the detailed follow-up and screenshot. Your checkbox naming and the expanded HDRL/LDL/RAD arrays look fine. The issue appears to be where the JavaScript is being triggered.

    Please don't use Mouse Enter for this. Mouse Enter runs when the pointer enters the dropdown field, not when a new dropdown value has actually been selected.

    Instead, try the following:

    1. Open the dropdown Properties > Options and keep Commit selected value immediately checked.
    2. Go to Properties > Validate.
    3. Select Run custom validation script > Edit and place the script there.
    4. Use the dropdown's selected value in the script: 

     

    var groups = {

        "HDRL": ["cb1","cb2","cb3","cb4","cb5","cb6","cb7","cb8","cb9","cb10","cb11","cb12","cb13"],

        "LDL":  ["cb14","cb15","cb16","cb17","cb18","cb19"],

        "RAD":  ["cb20","cb21","cb22"]

    };

    var allBoxes = [

        "cb1","cb2","cb3","cb4","cb5","cb6","cb7","cb8","cb9","cb10","cb11",

        "cb12","cb13","cb14","cb15","cb16","cb17","cb18","cb19","cb20","cb21","cb22"

    ];

    // Clear all checkboxes

    for (var i = 0; i < allBoxes.length; i++) {

        this.getField(allBoxes[i]).value = "Off";

    }

    // Check boxes for the selected lab group

    var selected = event.value;

    if (groups[selected]) {

        for (var j = 0; j < groups[selected].length; j++) {

            this.getField(groups[selected][j]).checkThisBox(0, true);

        }

    }

     

    Also verify that the dropdown values are exactly HDRL, LDL, and RAD, including capitalization and without extra spaces. With Commit selected value immediately enabled, the validation script should run when the selection is committed. Community guidance for Acrobat combo boxes confirms this behavior. Suggested discussion: 

     

    With this setup, choosing HDRL, LDL, or RAD should clear the previous group and select only the corresponding checkboxes. Selecting the blank entry should leave all checkboxes cleared.

    Let us know how it goes.

    Regards,

    Anand Sri.

    7 replies

    Participant
    Nov 3, 2026 7:55 PM UTC

    Tried this and it didn’t work.  I want to make sure that I am adding the java script in the right location.  Here’s what I am doing:

    For the checkboxes:

    1. Right click on each box and select “Properties”
      1. Under General tab:
        1. Change “Name” to “cb1” or “cb2”, or “cb3”, etc
        2. Keep Tooltip blank

    For the drop down menu:

    1. Right click on drop-down menu and select “Properties”
    2. Under “Options” tab:
      1. make sure that “Commit select value immediately” is checked
    3. Under “Actions” tab:
      1. the “Select Trigger” is “Mouse Enter”
      2. the “Select Action” is “Run a javaScript”
      3. Click “Add” button
      4. Paste in script from above 
      5. Click close
    4. Select Preview and test if different drop down lab names cause boxes to automatically be checked.  
    5. When selecting different groups nothing occurs

     

    Below is a screen shot of this form showing the drop down menu and the resulting boxes.  There are more labs than what I initially reported.  I just reported 3 for each group to make it simplier to explain.  There are actually HDRL = 13 labs; LDL = 6 labs; RAD = 3 labs).

    Also my script that I updated to reflect the additional labs is below:

    var groups = {

        "HDRL": ["cb1", "cb2", "cb3", "cb4", "cb5", "cb6", "cb7", "cb8", "cb9", "cb10", "cb11", "cb12", "cb13"],

        "LDL":  ["cb14", "cb15", "cb16", "cb17", "cb18", "cb19"],

        "RAD":  ["cb20", "cb21", "cb22"]

    };

    var allBoxes = ["cb1","cb2","cb3","cb4","cb5","cb6","cb7","cb8","cb9", "cb10", "cb11", "cb12", "cb13", "cb14","cb15","cb16","cb17", "cb18", "cb19", "cb20", "cb21", "cb22"];

    // Clear all checkboxes first

    for (var i = 0; i < allBoxes.length; i++) {

        this.getField(allBoxes[i]).value = "Off";

    }

    // Check only the boxes associated with the selected lab group

    var selected = event.value;

    if (groups[selected]) {

        for (var j = 0; j < groups[selected].length; j++) {

            var f = this.getField(groups[selected][j]);

            f.checkThisBox(0, true);

        }

    }

     

    Translate
    Anand Sri Bhattacharya
    Community Manager
    Community Manager
    Nov 4, 2026 9:52 AM UTC

    Hello ​@Malcolm28876973cmri 

     

    Thanks for the detailed follow-up and screenshot. Your checkbox naming and the expanded HDRL/LDL/RAD arrays look fine. The issue appears to be where the JavaScript is being triggered.

    Please don't use Mouse Enter for this. Mouse Enter runs when the pointer enters the dropdown field, not when a new dropdown value has actually been selected.

    Instead, try the following:

    1. Open the dropdown Properties > Options and keep Commit selected value immediately checked.
    2. Go to Properties > Validate.
    3. Select Run custom validation script > Edit and place the script there.
    4. Use the dropdown's selected value in the script: 

     

    var groups = {

        "HDRL": ["cb1","cb2","cb3","cb4","cb5","cb6","cb7","cb8","cb9","cb10","cb11","cb12","cb13"],

        "LDL":  ["cb14","cb15","cb16","cb17","cb18","cb19"],

        "RAD":  ["cb20","cb21","cb22"]

    };

    var allBoxes = [

        "cb1","cb2","cb3","cb4","cb5","cb6","cb7","cb8","cb9","cb10","cb11",

        "cb12","cb13","cb14","cb15","cb16","cb17","cb18","cb19","cb20","cb21","cb22"

    ];

    // Clear all checkboxes

    for (var i = 0; i < allBoxes.length; i++) {

        this.getField(allBoxes[i]).value = "Off";

    }

    // Check boxes for the selected lab group

    var selected = event.value;

    if (groups[selected]) {

        for (var j = 0; j < groups[selected].length; j++) {

            this.getField(groups[selected][j]).checkThisBox(0, true);

        }

    }

     

    Also verify that the dropdown values are exactly HDRL, LDL, and RAD, including capitalization and without extra spaces. With Commit selected value immediately enabled, the validation script should run when the selection is committed. Community guidance for Acrobat combo boxes confirms this behavior. Suggested discussion: 

     

    With this setup, choosing HDRL, LDL, or RAD should clear the previous group and select only the corresponding checkboxes. Selecting the blank entry should leave all checkboxes cleared.

    Let us know how it goes.

    Regards,

    Anand Sri.

    Translate
    Participant
    Nov 4, 2026 4:50 PM UTC

    Anand Sri,

     

    THAT WORKED!!! Thanks so much for your help.  I really appreciate it.

     

    Malcolm

    Translate
    justlearn
    Community Expert
    Community Expert
    Nov 3, 2026 5:38 AM UTC

    ​@Malcolm28876973cmri I do my forms a little different than ​@Anand Sri Bhattacharya does. 

    I have a form. Or I create a form (Prepare Form)


    I would double-click on the ‘blue’ properties — which a Text Field Properties dialog box wll open:
     


    My first check-box, is undefined, so, I will manually rename bothe the name and tooltip. I will rename them as HDRL. If I have more than one HDRL, then it would be HDRL1, HDRL2, and so on
     

    And do the rest of the check boxes
     


    When all the check boxes are done. Click on Close.

    It may be easier if you are not comfortable doing scripting. 

    Translate
    m
    Participant
    Nov 3, 2026 7:31 PM UTC

    Tried this and it didn’t work.  I’m not sure how just renaming the check box name and tooltip within it’s properties menu would cause them to be automatically be checked when selecting HDRL/LDL/RAD a separate drop down menu.  Please explain.

    Translate
    Anand Sri Bhattacharya
    Community Manager
    Community Manager
    Nov 2, 2026 8:24 PM UTC

    Hello @Malcolm28876973cmri


    I hope you are doing well, and thanks for reaching out. Sorry for the trouble.


    You can try this with a small JavaScript attached to the dropdown field. I’d first clear all nine checkboxes and then check only the group associated with the selected dropdown value.

    Assuming your dropdown export values are exactly HDRL, RAD, LDL, and blank, you can use:


    var groups = {

        "HDRL": ["cb1", "cb2", "cb3"],

        "RAD":  ["cb4", "cb5", "cb6"],

        "LDL":  ["cb7", "cb8", "cb9"]

    };

    var allBoxes = ["cb1","cb2","cb3","cb4","cb5","cb6","cb7","cb8","cb9"];

    // Clear all checkboxes first

    for (var i = 0; i < allBoxes.length; i++) {

        this.getField(allBoxes[i]).value = "Off";

    }

    // Check only the boxes associated with the selected lab group

    var selected = event.value;

    if (groups[selected]) {

        for (var j = 0; j < groups[selected].length; j++) {

            var f = this.getField(groups[selected][j]);

            f.checkThisBox(0, true);

        }

    }


    Or,


    var groups = {

    HDRL: 1,

    RAD: 4,

    LDL: 7

    };

    var first = groups[event.value];

    for (var i = 1; i <= 9; i++) {

    var shouldCheck =

    first !== undefined && i >= first && i < first + 3;

    this.getField("cb" + i).checkThisBox(0, shouldCheck);

    }



    Add the script to the dropdown's appropriate selection action. Because the script clears the boxes first, selecting the blank entry will leave all nine unchecked. Also make sure the dropdown's export values match HDRL, RAD, and LDL exactly, and that the checkbox field names are exactly cb1 through cb9.

    Note: This is a sample script and may or may not work in your environment, as you might have to make changes depending on the PDF form type, app version, etc.


    To learn more about the JavaScripts in Acrobat and PDF forms, please refer to this article: https://adobe.ly/4A9uCnb


    Hope this helps, and please reach out if you need any assistance.

    Regards,

    Anand Sri.

    Translate