JS Tips and Tricks

Select all checked checkbox in given tables

var favorite = [];
 $.each($("#resultTable input:checked"), function(){ 
 favorite.push($(this).val());
 });
var data = {};
data["campaign"] = favorite.join(",");
//data["campaign"] = favorite;
 //console.log(favorite);
 //console.log(favorite.join(","));
 console.log(data);

Select all check boxes

$('#resultTable').find('input:checkbox').prop('checked', true);

De-Select all Checkboxe (s)

$('#resultTable').find('input:checkbox').prop('checked', false);

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s