Skip to main content
Known Participant
October 17, 2023
Answered

DropDown Selection to check boxes 2

  • October 17, 2023
  • 2 replies
  • 4471 views

Hello, 

           I made a posting here a while back under the same title. I am not sure how to revive an old posting here. If there is a way to do so please let me know for future posting. But for reference this is the link to the old posting 

https://community.adobe.com/t5/acrobat-discussions/dropdown-selection-to-check-boxes/m-p/13890497#M417058

 

So I have this script that I am currently using 

if(event.value=="MARRIED")

this.getField("QAB MARTIAL").checkThisBox(0,true);

else if (event.value=="SINGLE"  || event.value=="WIDOW" || event.value=="WIDOWED")

this.getField("QAB MARTIAL").checkThisBox(2,true);

else if (event.value=="DIVORCED")

this.getField("QAB MARTIAL").checkThisBox(1,true);

 

But I just got a new check box of Dual Military that was added, and I am looking to add Dual Military to this script so it will work properly. I have already added Dual Military to the dropdown, so this is the last step, and I am not sure how to add it to this script without jacking it all the way up. I'm sure it is simple. How would I go about adding it? Is it as simple as duplicating one of the else if, changing the even and heading a 3, true?

 

Please help; thank you greatly in advance

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

Well damn. So focused on duplicating what I had on the original the example was messed up. Ugh. Thank you. 

Now that I fixed the example version, no my issue is the single check box does not reflect as I other check boxes do. 


In checkboxes, use script as 'Mouse Up' action, not 'Mouse Enter'.

2 replies

Thom Parker
Community Expert
Community Expert
October 17, 2023

You can simplify the code by making the export values in the dropdown the same as the export values of the checkboxes. 

Then the code would be a single line that didn't need to be updated when new entries were added:

 

this.getField("QAB MARTIAL").value = event.value;

 

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Known Participant
October 17, 2023

I am sorry I am not good at this would you mind breaking that down a bit more please. I am all about simplier

 

 
Nesa Nurani
Community Expert
Community Expert
October 17, 2023

Add another 'else if'.

If it's part of the same checkbox/radio button group, then yes, use 3.

It's the best way for you to just test it and see if it works.

Known Participant
October 17, 2023

I attempted to make this work and now my backfeed script does not work. Like when I click a box it doesn't change the dropdown. 

 

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

this.getField("MARTIAL STATUS").value = event.target.value;}

 

 

Do i need to change the script again too?

Thom Parker
Community Expert
Community Expert
October 17, 2023

The very first thing to do is look in the console window so see if any errors are reported. Do this and let us know what you see.

 

There is an issue with the checkbox script causing the dropdown script to run (since I believe you are using a custom validation?), but everything should balance out. 

 

 

 

 

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often