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

Dropdown to populate checkbox with either of two different values checking same box

New Here ,
Jun 28, 2024 Jun 28, 2024

Thanks in advance for your help!

 

I have a dropdown with three options:

Yes.

No because A.

No because B.

 

Later in the form, I want either a "yes" checkbox automatically checked or the "no" checkbox.

I can get the "yes" to work fine, but can't get the script to use both "no" responses--it just takes one. I'm sure I'm missing something little, but don't know what. Any suggestions? Thanks!

 

this.getField("LEP Special Factor Response Confirm No").checkThisBox(0,event.value == "No. The child's home language is English." ? true : false);
this.getField("LEP Special Factor Response Confirm No").checkThisBox(0,event.value == "No. The child's home language is not English, but they demonstrates appropriate English proficiency." ? true : false);
this.getField("LEP Special Factor Response Confirm Yes").checkThisBox(0,event.value == "Yes. The child demonstrates limited English proficiency." ? true : false);

 

TOPICS
How to , JavaScript , PDF forms
590
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
2 ACCEPTED SOLUTIONS
Community Expert ,
Jun 28, 2024 Jun 28, 2024

The second statement for the "No" checkbox is cancelling out the first.  Change your script to 

 

 

this.getField("LEP Special Factor Response Confirm No").checkThisBox(0,(event.value == "No. The child's home language is English." || event.value=="No. The child's home language is not English, but they demonstrates appropriate English proficiency.")? true: false);
this.getField("LEP Special Factor Response Confirm Yes").checkThisBox(0,event.value == "Yes. The child demonstrates limited English proficiency." ? true: false);

 

View solution in original post

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 ,
Jun 28, 2024 Jun 28, 2024

Assuming your check boxes are mutually exclusive, an easier way to write this script is to name the two checkboxes identically, with one export value as "Yes" and the other as "No".  Then add Yes and No export values to the dropdown statements.  Add the following custom keystroke script to the dropdown (assuming checkbox name is "Checkbox 1"):

 

if(!event.willCommit)

{this.getField("Checkbox 1").value=event.changeEx;}

View solution in original post

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 ,
Jun 28, 2024 Jun 28, 2024

Where is your script located?

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
New Here ,
Jun 28, 2024 Jun 28, 2024

Within the dropdown properties under Validate.

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 ,
Jun 28, 2024 Jun 28, 2024

The second statement for the "No" checkbox is cancelling out the first.  Change your script to 

 

 

this.getField("LEP Special Factor Response Confirm No").checkThisBox(0,(event.value == "No. The child's home language is English." || event.value=="No. The child's home language is not English, but they demonstrates appropriate English proficiency.")? true: false);
this.getField("LEP Special Factor Response Confirm Yes").checkThisBox(0,event.value == "Yes. The child demonstrates limited English proficiency." ? true: false);

 

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
New Here ,
Jun 28, 2024 Jun 28, 2024

Thanks so much! I knew that was happening, but had no idea how to fix it. Appreciate the 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 ,
Jun 28, 2024 Jun 28, 2024

Assuming your check boxes are mutually exclusive, an easier way to write this script is to name the two checkboxes identically, with one export value as "Yes" and the other as "No".  Then add Yes and No export values to the dropdown statements.  Add the following custom keystroke script to the dropdown (assuming checkbox name is "Checkbox 1"):

 

if(!event.willCommit)

{this.getField("Checkbox 1").value=event.changeEx;}

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
New Here ,
Jun 28, 2024 Jun 28, 2024
LATEST

Great! I'll try this, too. Googling for answers sometimes finds more complicated solutions than necessary! I appreciate the 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