Skip to main content
Participating Frequently
April 10, 2024
Answered

if checkbox is true, radio buttons are false

  • April 10, 2024
  • 1 reply
  • 1118 views

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.

 

This topic has been closed for replies.
Correct answer try67

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

1 reply

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
April 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";
}
Participating Frequently
April 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

Participating Frequently
April 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.


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