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

Javascript - Dropdown list select different check box items

New Here ,
Dec 10, 2022 Dec 10, 2022

Hi all,

 

I have done research and found answers for drop down dependency lists, however my example i need help with is i have a new form, from the drop down list if you select new , or returning from the drop down list i would like the check boxes which are visible below to preselect certain check boxes as the requirements will change between new and returning.

 

any help, thank you in advance.

TOPICS
JavaScript
1.5K
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
1 ACCEPTED SOLUTION
Community Expert ,
Dec 11, 2022 Dec 11, 2022

Use this:

for(var i=1; i<=15; i++){
if(event.value == "New")
this.getField("course "+i).checkThisBox(0,true);
else if(event.value == "Returning"){
this.getField("course "+i).checkThisBox(0,false);
if(i==1 || i==3)
this.getField("course "+i).checkThisBox(0,true);}
else if(event.value == "Soon"){
this.getField("course "+i).checkThisBox(0,false);
if(i>=5&&i<=8)
this.getField("course "+i).checkThisBox(0,true);}
else
this.getField("course "+i).checkThisBox(0,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 ,
Dec 10, 2022 Dec 10, 2022

So you want to check checkboxes if either 'New' or 'Returning' is selected from dropdown?

Lets say checkboxes are named "New" and "Returning", you can use this as validation script of dropdown field:

this.getField("New").checkThisBox(0, event.value == "New" ? true : false);
this.getField("Returning").checkThisBox(0, event.value == "Returning" ? 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 ,
Dec 11, 2022 Dec 11, 2022

Hi Nesa,

 

Thank you for replying.

 

So i have 5 things in the drop down.

 

New

List

Soon

Returning

Finish

 

and i have around 15 different things in the checkbox on same page of form.

 

course 1 

course 2

course 3

upto course 15

 

I would like for example, if new is select that all check boxes are ticked but if returning is select only check box 1 and 3 are ticked.

 

If soon is ticked and then check box 5-8 is ticked?

 

 

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 ,
Dec 11, 2022 Dec 11, 2022

Use this:

for(var i=1; i<=15; i++){
if(event.value == "New")
this.getField("course "+i).checkThisBox(0,true);
else if(event.value == "Returning"){
this.getField("course "+i).checkThisBox(0,false);
if(i==1 || i==3)
this.getField("course "+i).checkThisBox(0,true);}
else if(event.value == "Soon"){
this.getField("course "+i).checkThisBox(0,false);
if(i>=5&&i<=8)
this.getField("course "+i).checkThisBox(0,true);}
else
this.getField("course "+i).checkThisBox(0,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 ,
Dec 11, 2022 Dec 11, 2022
LATEST

Thank you so much Nesa. This worked perfectly.

 

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