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

Javascript - Dropdown list select different check box items

New Here ,
Dec 10, 2022 Dec 10, 2022

Copy link to clipboard

Copied

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

Views

732

Translate

Translate

Report

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

correct answers 1 Correct answer

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);}

Votes

Translate

Translate
Community Expert ,
Dec 10, 2022 Dec 10, 2022

Copy link to clipboard

Copied

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);

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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?

 

 

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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);}

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

LATEST

Thank you so much Nesa. This worked perfectly.

 

Votes

Translate

Translate

Report

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