Multi-select with shift on HTML table

Well I was looking into adding a shift select on a checkbox table. After performing a quick search I found a jquery plugin. This was a great start, but I found it would not unselect successfully. I made some minor modifications and now it appears to work in IE9 and FF...

  function toggleSelected(element, shouldSelect) {
    $(element).attr("checked", shouldSelect);
    } else {
  $.fn.shiftSelectTable = function(){
    var $table = $(this);
      var last = $"jquery-shift-select-table.last");
      $"jquery-shift-select-table.last", $(this).get());
      if(last == null || !event.shiftKey) {
      else {
        var shouldSelect = $(this).attr("checked");
        var $checkboxes = $table.find(":checkbox");
        var currentIndex = $checkboxes.index(this);
        var lastIndex = $checkboxes.index($(last));
        var $checkboxesToChange = (currentIndex >= lastIndex) ? $checkboxes.slice(lastIndex, currentIndex+1) : $checkboxes.slice(currentIndex, lastIndex+1);
          toggleSelected(this, shouldSelect);

    return this;


Popular posts from this blog

IE9 Intranet compatibility mode in Intranet websites

Intersystems Caché performance, woe is me...

How to make CSS3 Windows 7 buttons