Skip to main content
Inspiring
May 29, 2023
Question

dropdown selection auto-selecting checkbox

  • May 29, 2023
  • 2 replies
  • 695 views

Know this subject has been answered many times, because I've tried all the solutions listed, even tweaking them here and there, running as 'mouse-up' script, Nesa's validation script, and inserting into an existing custom calculation script, all in the dropdown field- and all to no avail. In short, I have a dropdown with four choices and their export values 1, 2, 3, 4 respectively. I have two target checkboxes (Box1, Box2) on the next page of the form. Dropdown selections 1, 2, 3 need to "Check" Box1, while Dropdown selection 4 needs to "Check" Box2. The following custom validation script worked, but when the dropdown selection was changed to another selection, nothing changes, stays the same. I need the ability to "Check/Uncheck" Box1 and Box2 when switching the Dropdown selections to reflect the right association between the dropdown selection and the "checking/unchecking" of the Boxes 1, 2.. Spent a day and half on this- so really need some guidance on detangling what's left of my mind! Thanks in advance!!

This topic has been closed for replies.

2 replies

Nesa Nurani
Community Expert
Community Expert
May 30, 2023

Remove other scripts (if you have any) and use this in dropdown field as 'Custom calculation script':

this.getField("Box1").checkThisBox(0, event.value == 1 || event.value == 2 || event.value == 3 ? true : false);
this.getField("Box2").checkThisBox(0, event.value == 4 ? true : false);

Inspiring
May 30, 2023

Thank you Bernd and Nesa for your replies. Nesa, the custom calculation script that you provided works as intended, but I'm still experiencing not being able to switch between dropdown selections and their target Box. Both Boxes 1 and 2 remain "checked" when swapping between dropdown selections, rather than  dropdown selections 1 - 3 checking Box 1 whilst unchecking Box 2 if its dropdown selection (4) was mistakenly selected by the user and subsequently changed, and vice versa. Is this possible? Also, I had a custom calculation script to show/hide other unrelated textfields and for this I had each dropdown selection using if/else statement to show/hide these text fields. I mentioned this b/c I modified your 1st statement by separating the individual dropdown selections into separate this.getField ... statements, and inserted each one into their resective 'if' statements separated by the curly brackets {}. Don't know if this adversely affected your original solution, but that's been plaguing me now for some time. Thank you both again for your guidance, not just here but for all your  posts- extremely helpful!!!

Bernd Alheit
Community Expert
Community Expert
May 30, 2023

What validation script does you use?