How to limit the number of checkboxes to be selected using php???
ashiiiish 0 Newbie Poster
Recommended Answers
Jump to PostCheckboxes are limited via HTML.. They'll be already limited when they appear in the page you create.
Jump to PostYou need JS. If you're using jQuery, you could do something like this (if not, it's the same thing but it would take quite a bit more coding):
$('input:checkbox').click(function(){ $('input:checkbox:not(:checked)').attr('disabled', $('input:checkbox:checked').length >= 3 ? 'disabled' : ''); });
Jump to PostWell, you could also count the amount of selected boxes with php and echo a warning if it's > 3, of course, but personally I'd definitely use JS for this.
All 11 Replies
vibhaJ 126 Master Poster
Pro2000 29 Posting Whiz
ashiiiish 0 Newbie Poster
karthik_ppts 81 Posting Pro
twiss 155 Veteran Poster
ashiiiish 0 Newbie Poster
twiss 155 Veteran Poster
divyakrishnan 20 Junior Poster
twiss 155 Veteran Poster
divyakrishnan 20 Junior Poster
ashiiiish 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.