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
http://jsfiddle.net/dw6Hf/46/
Thanks
You can show message like this Live Demo
$('#divmsg').html($(".ui-selected").length + " box selected")
if ($(".ui-selected").length > 4) {
$('#divmsg').html($('#divmsg').html() + ", Selection of only 4 allowed");
$(".ui-selected").each(function(i, e) {
if (i > 3) {
$(this).removeClass("ui-selected");
}
});
return;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With