• 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: checkbox selection limit

checkbox selection limit 9 years 6 months ago #32916

  • jason35
  • jason35's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 5
  • Thank you received: 1
Need help please.
Could anyone tell me if there is a way to limit the number of checkbox selections as the form is being completed. i.e. if you are filling out the form and there are 10 checkboxes (and the limit is 3) you select 3 and a 4th cannot be selected until you uncheck one of the previous 3.

Thanks :)
Jason
The administrator has disabled public write access.

checkbox selection limit 9 years 6 months ago #32921

  • alexp
  • alexp's Avatar
  • OFFLINE
  • RSJoomla! Official Staff
  • Posts: 2253
  • Thank you received: 180
Please note: my help is not official customer support. To receive your support, submit a ticket by clicking here
Regards,
RSJoomla! Development Team
The administrator has disabled public write access.

checkbox selection limit 9 years 5 months ago #33065

  • jason35
  • jason35's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 5
  • Thank you received: 1
I did a search but didn't find anything that worked like I need it to

Can anyone help
The administrator has disabled public write access.

checkbox selection limit 9 years 5 months ago #33066

  • alexp
  • alexp's Avatar
  • OFFLINE
  • RSJoomla! Official Staff
  • Posts: 2253
  • Thank you received: 180
Did you check the provided forum post ?
Please note: my help is not official customer support. To receive your support, submit a ticket by clicking here
Regards,
RSJoomla! Development Team
The administrator has disabled public write access.

checkbox selection limit 9 years 5 months ago #33073

  • jason35
  • jason35's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 5
  • Thank you received: 1
I did try it but it only validates when the user submits the form. I found that I need some java code to do it as the user completes the form but I am struggling to modify it to recognize the checkbox in the form.
The administrator has disabled public write access.

checkbox selection limit 9 years 5 months ago #33082

  • jason35
  • jason35's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 5
  • Thank you received: 1
So is seems I need an "onclick function" in the additional attributes but for the ;ife of me cannot get it to limit the number of checkboxes selected

Any help please
The administrator has disabled public write access.

checkbox selection limit 9 years 5 months ago #33084

  • alexp
  • alexp's Avatar
  • OFFLINE
  • RSJoomla! Official Staff
  • Posts: 2253
  • Thank you received: 180
Can you post an URL to your form so we can have a look ?
Please note: my help is not official customer support. To receive your support, submit a ticket by clicking here
Regards,
RSJoomla! Development Team
The administrator has disabled public write access.

checkbox selection limit 9 years 5 months ago #33085

  • adrianp
  • adrianp's Avatar
  • OFFLINE
  • RSJoomla! Official Staff
  • Posts: 631
  • Thank you received: 146
Hello,

You can try using the following JavaScript (while editing a form > Properties > CSS and JavaScript > JavaScript), including the <script> tags:
<script type="text/javascript">
function limitCheck(val,name,limit){
	var checkElement = document.getElementsByName(name);
	var counter = 0;
	for(var i=0; i < checkElement.length; i++){
		if(checkElement[i].value != val && checkElement[i].checked === true){
			counter++;
		}
		if(checkElement[i].value == val){
			var actualSel = checkElement[i];
		}
	}
	if(counter >= limit){
		actualSel.checked = false;
	}
}
</script>

Finally, add the following trigger on your checkbox element (edit the checkbox > Attributes > "Additional Attributes" area):
onclick="limitCheck(this.value,this.name,3);"

Whereas 3 is the limit you want to impose.
This is not official customer support. To receive your support, submit a support ticket here.
Last Edit: 9 years 5 months ago by adrianp. Reason: Improved
The administrator has disabled public write access.
The following user(s) said Thank You: Roberts, evetacm, eiverson

checkbox selection limit 9 years 5 months ago #33093

  • jason35
  • jason35's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 5
  • Thank you received: 1
Thank you so much Adrianp, works perfectly. You my friend have saved me from tearing my hair out. B) B) B)
The administrator has disabled public write access.
The following user(s) said Thank You: evetacm
  • 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!