have this fiddle and i would like to make it count the number of boxes that are selected. Now it shows the numbers of the boxes.
Any idea how to do it??
$(function() {
$(".selectable").selectable({
filter: "td.cs",
stop: function() {
var result = $("#select-result").empty();
var result2 = $("#result2");
$('.ui-selecting:gt(31)').removeClass("ui-selecting");
alert($(".ui-selected").length);
if ($(".ui-selected").length > 4) {
$(".ui-selected", this).each(function(i, e) {
if (i > 3) {
$(this).removeClass("ui-selected");
}
});
return;
}
$(".ui-selected", this).each(function() {
var cabbage = this.id + ', ';
result.append(cabbage);
});
var newInputResult = $('#select-result').text();
newInputResult = newInputResult.substring(0, newInputResult.length - 1);
result2.val(newInputResult);
}
});
});
my problem is to show the result of maximum selected boxes allowed. for example if you select 8 boxes to show only 4 and get result of 4 that is the maximum alowed. And finaly not to be an alert, to show in div tag or similar
Thanks
You can show message like this Live Demo