• 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!

TOPIC: Checked boxes and automatic uncheck

Checked boxes and automatic uncheck 10 years 3 months ago #30097

  • jsarris
  • jsarris's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 2
Hello everyone,

I have some questions about checkboxes fields. There are two scenarios and I would like some help.

1st scenario: I have a checkbox group and I already have one choice default with [c] syntax. Alright so far. My question is: How can I disable the possibility of the user to uncheck this choice?

2nd scenario: I want to make a checkbox group with some choices and the last choice will be the "none of the above".
The question is: Is it possible to uncheck all other choices automatically when the last choice will be checked?

I hope you understand my questions and I'm waiting anyone's response.

Thanks a lot for your time.
The administrator has disabled public write access.

Checked boxes and automatic uncheck 10 years 3 months ago #30118

  • cosmin.cristea
  • cosmin.cristea's Avatar
  • OFFLINE
  • Platinum Boarder
  • Posts: 756
  • Thank you received: 144
Unchecking the other checkboxes upon selecting a "none of the above" box, can be done by using the following snippet in your CSS and Javascript section to achieve both of the results
<script>
jQuery(document).ready(function(){
	jQuery('[id^="checkboxid"]').click(function(){ //bind the function on click
		if ($(this).value == 'none'){ //find the checkbox that if clicked, remove the others
			var uncheckThis = jQuery('[id^="checkboxid"]').not('[value="none"]');//grab the others
			uncheckThis.prop( "checked", false );//uncheck them
		} else if ($(this).value != 'none'){
			var uncheckThis =  jQuery('[id^="checkboxid"]').filter('[value="none"]');	//select the other checkboxes
			uncheckThis.prop( "checked", false );//uncheck that other box
		}
	})
});
</script>

Please note that the above code is merely an example, and you should change accordingly id of the checkboxes, and the value of the checkbox that when clicked, unchecks the others.

Also, you need to have jQuery loaded on your website (if you provide a URL for your form I can provide further information)
My help is not official customer support. To receive your support, submit a ticket by clicking here
The administrator has disabled public write access.
  • 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!