tags:

views:

57

answers:

2

I used this code to select top 5 users from jQuery grid on button click..

$('#myButton').click(function() {
    $('#Grid input[type=checkbox]:lt(5)').attr('checked','checked');
});

Its working fine if I click the button it checks the check boxes. After checking any box, there is another button to send the selected user to the other page, if not pop up message to select at least one user...

The above code I implemented checks the boxes fine, but if I click send it pops up the select a user message.

What do I need to do?

Thanks

A: 

UPDATE:

DEMO: http://jsbin.com/ageba3

you need to have something like this:

assuming #send is your send button!

 $('#send').click(function(e) {
        e.preventDefault();
        if ( $('#Grid input:checkbox').is(':checked') ) {
         //open popup
        } else {
        //do nothing
        }
  });
aSeptik
+1  A: 
$('#anotherButton').click(function() {
    if( $('#Grid input[type=checkbox]:checked').length ) {
        // At least one is checked
    } else {
        // None are checked
    }
});

EDIT:

Reversed the logic. Not sure why I decided to negate the first time.

patrick dw
nice implementation `$('#Grid input[type=checkbox]:checked').length`
aSeptik