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

if checkbox is true, radio buttons are false

Community Beginner ,
Apr 10, 2024 Apr 10, 2024

Hello,

    I do not have much knowledge of javascript, and i am trying to put a form together for people to fill out.  in one section i have a checkbox that is a "No To All Below" and the i have about 7 seperate groups of radio bottons each with a "Yes" and "No".  i am hoping it is possible, and if so: where i would need to put something that would make all the radio buttons automatically say "No" when checkbox is checked.  thank you for any help.

 

TOPICS
Create PDFs , JavaScript , PDF , PDF forms
757
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 ,
Apr 10, 2024 Apr 10, 2024

As the Mouse Up event of that check-box field enter the following code (let's assume the export value of that box is "NoAll" and that the radio-button groups are named "Radio1" to "Radio7" with export values of Yes and No):

 

if (event.target.value=="NoAll") {
	for (var i=1; i<=7; i++) this.getField("Radio"+i).value = "No";
}

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

As the Mouse Up event of that check-box field enter the following code (let's assume the export value of that box is "NoAll" and that the radio-button groups are named "Radio1" to "Radio7" with export values of Yes and No):

 

if (event.target.value=="NoAll") {
	for (var i=1; i<=7; i++) this.getField("Radio"+i).value = "No";
}
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 ,
Apr 10, 2024 Apr 10, 2024

Hello, thank you very much for responding, but for some reason i can not get it to work.  i have changed the names of the radio groups to be TBQues1 to TBQues7 and then made sure the checkbox value is what you have, but i'm not getting anything to populate a change when i click the checkbox. i did not get any errors when saving either

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

Check the JS Console (Ctrl+J) for errors after clicking the check-box.

If you still can't solve it, please share the file for further 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 Beginner ,
Apr 10, 2024 Apr 10, 2024
LATEST

I got it to work, thank you so much, i had a space in the first radio button group name, so it was erroring out there, and i didn't see it until you mentioned to console.  thank you 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 Expert ,
Apr 10, 2024 Apr 10, 2024

Did you change "Radio" to "TBQues" in script?

If you are not sure if checkbox value is "NoAll" you can use like this:  if (event.target.value !== "Off") {

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