Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How to have a checkbox automatically populate other specific boxes.

Explorer ,
Oct 08, 2024 Oct 08, 2024

Hi 

I am new to creating forms but I am trying to edit a form we currently use so that if I check that specific box then certain boxes (yes boxes on the form) will automatically  check when the first box at top of form is checked. Would this be possible 

 

For example the box at the top is all clear and if that one is checked yes then all other yes boxes to be checked automatically.  

 

Thank you for any help. 

TOPICS
General troubleshooting , How to , JavaScript , PDF , PDF forms
2.0K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 08, 2024 Oct 08, 2024

Hi 

I am new to creating forms but I am trying to edit a form we currently use so that if I check that specific box then certain boxes (yes boxes on the form) will automatically  check when the first box at top of form is checked. Would this be possible 

 

For example the box at the top is all clear and if that one is checked yes then all other yes boxes to be checked automatically.  

 

Thank you for any help. 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 08, 2024 Oct 08, 2024

is this an acrobat question?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 08, 2024 Oct 08, 2024

Copy the check box fields so they have the same name same export value.  You can copy the fields in form editing mode by selecting the field, then pressing Ctrl + c (copy), the Ctrl +v (paste).

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 08, 2024 Oct 08, 2024

Hi when i did this they all checked but then if i only wanted one box to work they all did due to the same name. Is there a way to add a script so that if the "all clear" box is checked then they check yes but if the "all clear" box is not checked then they will work as normal? Its for a vehicle inspection form so sometimes not everything is a yes but we wanted to see if it would be possible to have one box at the top that if when check will automatically populate all the others correctly so that the vehcile is considered all clear. I hope that makes sense? 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 08, 2024 Oct 08, 2024

I attached a picture of part of our form for reference.  But on certain parts the check box would be a no instead of yes. 

Example full tank yes 

interior damage no 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 08, 2024 Oct 08, 2024

OK.  You won't be able to copy the fields as a described.  They need to have different names.  What is the export value of the Yes boxes, "Yes"?  If so, create Mouse Up action in the Actions tab of the AllClear check box, and select "Run a JavaScript".  Then enter the following script:

if(event.target.value=="Yes")

{

this.getField("Checkbox 1").value="Yes";

this.getField("Checkbox 2").value = "Yes;

//etc.

}

 

Replace Checkbox 1 and Checkbox 2 with the actual field names.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 08, 2024 Oct 08, 2024

Yes all the boxes have the export value as "yes" 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 08, 2024 Oct 08, 2024

So in this script would checkbox 1 be the allclear box or one of my other boxes?  Sorry i am new to all this and still trying to figure it out so i want to make sure i don't mess up. 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 08, 2024 Oct 08, 2024

This script goes in the check box that controls the other boxes that it will check.  The other boxes in the script are Checkbox 1 and Checkbox 2.  Be aware that "Yes" is case sensitive.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 08, 2024 Oct 08, 2024

Thank you for your help. I copied and pasted the script above and changed the checkbox names but i am getting an error message. I attached a picture of the javascript box

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 08, 2024 Oct 08, 2024

You have a 0 instead of a closing bracket after "InteriorNo" in your script.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 08, 2024 Oct 08, 2024

If not sure about export values, it is better to check that checkbox is not "Off" or use 'isBoxChecked()'

if(event.target.value != "Off")

if(event.target.isBoxChecked(0))

and to check checkbox you can use

this.getField("Checkbox 1").checkThisBox(0,true);

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 08, 2024 Oct 08, 2024

Hi I added this script and it did check off the correct boxes but then when i unchecked it the other boxes remained checked. Is there a way to have all boxes uncheck as well if the original box is not checked? 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 08, 2024 Oct 08, 2024

That's what my first answer did, but you said you didn't want that.  Here's the modified script:

if(event.target.value=="Yes")

{

this.getField("Checkbox 1").value="Yes";

this.getField("Checkbox 2").value = "Yes;

//etc.

}

else

{

this.getField("Checkbox 1").value="Off";

this.getField("Checkbox 2").value = "Off";

}

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 08, 2024 Oct 08, 2024
LATEST

Thank you so much! This worked. I apologize I am new to all this so I don't think I fully understood when you asked me. Thank you again for all your help!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 08, 2024 Oct 08, 2024

You need to ask program questions in the forum for the program you are using
To ask in the forum for your program please start at https://community.adobe.com/
Moving from Using the Community (which is about the forums) to the correct forum

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines