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

if checkbox is true, radio buttons are false

Community Beginner ,
Apr 10, 2024 Apr 10, 2024

Copy link to clipboard

Copied

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

Views

459

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 , 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";
}

Votes

Translate

Translate
Community Expert ,
Apr 10, 2024 Apr 10, 2024

Copy link to clipboard

Copied

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

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

Copy link to clipboard

Copied

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

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

Copy link to clipboard

Copied

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.

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

Copy link to clipboard

Copied

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

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

Copy link to clipboard

Copied

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") {

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