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

Checkbox to Disable other checkboxes

Community Beginner ,
Jan 10, 2024 Jan 10, 2024

Hi there, I have a case assement checklist I am building for evaluating my teams cases.  I have a question and the option of Yes, No, and NA.  There are 23 questions and each Checkbox is lables Yes1, No1, NA1 ( repeats with a higher number to 23).  For each question, if someone selects a check box, I want the other two check boxes to disable.  Would this be possible?   

 

So for question 1,  if someone selects yes ( checkbox name yes1) I want checkbox No (checkbox name No1 and NA (checkbox name NA1) to disable.  

 

Thank you!! 

TOPICS
JavaScript , PDF forms
1.7K
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 ,
Jan 10, 2024 Jan 10, 2024

To do that you should rename the fields in each "group" so that they have the same name (such as "Question1") and unique export values (such as "Yes", "No", "N/A"). Then they would act as you've described automatically.

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 Beginner ,
Jan 10, 2024 Jan 10, 2024

So, my export value is set to 1 for each box, because I have it automatically tallying the number of yes and no responses to a total fields.  

 

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 ,
Jan 10, 2024 Jan 10, 2024

I recommend you change it. A simple script can be used to replace your calculation so that it still works with the new names and export values.

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 Beginner ,
Jan 10, 2024 Jan 10, 2024

Thank you! I have looked at some of the calculation scripts to try and calculate, but was struggling with them.  

I am new to building forms and looking at Java courses.  

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 ,
Jan 11, 2024 Jan 11, 2024

It's Javascript, though, not Java...

And if you need help with that code post here again.

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 Beginner ,
Jan 11, 2024 Jan 11, 2024

Thank you, Yes javascript is what I am looking into.  I will review the calculation suggestions I found and work through them and will post again if I have any questions.  I appreciate the suggestions! 

 

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 ,
Jan 11, 2024 Jan 11, 2024

Best approach to make checkboxes mutually exclusive is to give them same name and different export value as suggested by try67, but if you don't want to change them now you can use this script in any text field as custom calculation script(field can be hidden):

for(var i=1; i<=23; i++){
 var yes = this.getField("Yes"+i);
 var no = this.getField("No"+i);
 var na = this.getField("NA"+i);
 
if(yes.value !== "Off"){
 no.readonly = true;
 na.readonly = true;}
else if(no.value !== "Off"){
 yes.readonly = true;
 na.readonly = true;}
else if(na.value !== "Off"){
 yes.readonly = true;
 no.readonly = true;}
else{
 yes.readonly = false
 no.readonly = false;
 na.readonly = 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
Community Beginner ,
Jan 12, 2024 Jan 12, 2024

Thank you - If I can't figure out the calculation script to automaticaly tally the total number of checkboxes, Iw ill give this a try!  

 

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 Beginner ,
Jan 12, 2024 Jan 12, 2024
LATEST

Hi Nesa,  This worked perfectly!!  I have one more question.  I have 5 questions that are in a section, not related to the 23 original checkboxes.  This is just Yes and NA options.  I tried giving each question's checkbox the same name, but a different export value.  However, it is not making the option mutually exclusive.  Would the script you provided cause that?  

 

Thank you, 

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