Skip to main content
New Participant
January 27, 2023
Answered

How to make a dropdown selection select checkboxes

  • January 27, 2023
  • 6 replies
  • 10592 views

Hello,

 

Curious if it's possible to make a specific dropdown selection also populate specified checkboxes later on a .pdf form? Other options within the dropdown should not check any boxes. Is this possible? Thanks!

This topic has been closed for replies.
Correct answer Nesa Nurani

Use this:

this.getField("Staffing Needed").checkThisBox(0, event.value=="High*" || event.value=="Very High*");

6 replies

Participating Frequently
November 30, 2023

Hi, 

I want kind of same thing to happen. The dropdown name is "Dropdown2" and it has 2 values, yes and no. and there is a checkbox "checkbox2", i want this checkbox to be checked whatever option you choose from the dropdown. Can you please write the complete script, so i just copy and paste. thank you

Nesa Nurani
Community Expert
November 30, 2023

This doesn't make much sense to me, if there are only 2 values in the dropdown and checkbox will be checked no matter what selection is made, why not just check the checkbox manually and leave it checked?

Participating Frequently
November 30, 2023

It is a whole sheet with different tasks on it. I will do the rest, just wanted to had an idea. If i get it done by your help i will do the rest. It's a list of tasks, so task should be checked when you select an option from the dropdown. Hope you understand now. 

Nesa Nurani
Community Expert
February 2, 2023

In the dropdown field under 'Options' tab, check 'Commit selected value immediately' if you want the script to trigger without the need to click outside the field once you make the choice.

Use this as 'Validation script of dropdown field:

this.getField("Unbundled").checkThisBox(0,event.value == "DB" ? true : false);
this.getField("Check Box28").checkThisBox(0,event.value == "DB" ? true : false);
this.getField("Check Box29").checkThisBox(0,event.value == "DB" ? true : false);
this.getField("Check Box30").checkThisBox(0,event.value == "DB" ? true : false);
this.getField("Check Box26").checkThisBox(0,event.value == "DB" ? true : false);
this.getField("Check Box32").checkThisBox(0,event.value == "DB" ? true : false);

And here is your file with script added:

https://drive.google.com/file/d/1k_VO9gnLuMP3EdHsDPkvQD46eT9qN5DU/view?usp=share_link 

 

Lukas Engqvist
Community Expert
February 2, 2023

Thanks I see I didn't read the question correct

New Participant
January 30, 2023

Oh, that's great news! I would like for when 'DB' is selected in type of plan that the following options become checked:

  • Unbundled
  • N/A - Unbundled
  • N/A
  • N/A
  • N/A - Unbundled DB
  • N/A - Unbundled DB

 

And of course if something else is selected from the dropdown, these all become unchecked.

Lukas Engqvist
Community Expert
February 2, 2023

Make a structure to see what the checkboxes are called: 
You would beed something like: 

var myBox = this.getField("R1");
var myBox2 = this.getField("R2");

if (myBox.value === "Yes") {
    myBox2.value = "Yes";       
}

if (myBox.value !== "Yes") {
    myBox2.value= "";       
}

 Where R1 is the box you woould check and R2 is the box that is contolled by checking box R1.
I like to define the veriables to make script more reusable.

New Participant
January 27, 2023

I attached the document I'm looking at, I need when "DB" is selected in 'Type of Plan' that all of the other highlighted check boxes become checked. Sorry I should have attached the doc for context; would it still be possible?

ls_rbls
Community Expert
January 28, 2023

++ Adding to the discussion,

 

 

You can do that very easily with a script.

 

But what do you need to happen to the highlighted checkboxes when the user goes back and unchecks the DB checkbox?

 

Do you also need all of those checkboxes to become unchecked or leave them checked?

Joel Geraci
Community Expert
January 27, 2023

Where exactly do you need this to work? Do you have control over the application that will be used to fill the form?

Lukas Engqvist
Community Expert
January 27, 2023

Yes it is if you know JavaScript, and the document object model. But it will only work when viewing the PDF in Acrobat, though.