Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to select limited number of checkboxes with Jquery?
#1
Advertisment
See the code below and suggest that how can i select multiple check boxes in this code with a limit of maximum 3.

Select Models (Upto Five):

nclick="select_models(133);">  Accord

nclick="select_models(134);">  Accord Tourer

nclick="select_models(135);">  Acty

nclick="select_models(136);">  Acura

Advertisment
Reply
#2
Advertisment
Try this one it will work for you.
function select_models(id){
var checkboxes1 = $("#" +id);
var numBoxesChecked = ($('#'+checkboxes1+ ' p.width_33_fl input:checkbox:checked').length);
$(p.width_33_fl input[type="checkbox"]').filter(':not(:checked)').prop('disabled', numBoxesChecked >= 3);
}

It will select not more than 3 checkboxes.
Advertisment
Reply


Possibly Related Threads...
Thread Author Replies Views Last Post
  How to Access Dynamically loaded elements in Jquery Reham 0 734 12-07-2017, 10:20 AM
Last Post: Reham
  Tell Me What are the Benefits of Using Jquery Reham 1 3,418 03-19-2015, 04:19 PM
Last Post: Reham

Forum Jump:


Users browsing this thread: 1 Guest(s)