Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

24
LINES

< > BotCompany Repo | #1008423 // hCheckBoxMultiSelect - requires checkboxes to have class .chkbox

JavaX fragment (include)

1  
static S hCheckBoxMultiSelect() {
2  
  ret hscript([[
3  
var lastChecked = null;
4  
5  
$(document).ready(function() {
6  
    var $chkboxes = $('.chkbox');
7  
    $chkboxes.click(function(e) {
8  
        if(!lastChecked) {
9  
            lastChecked = this;
10  
            return;
11  
        }
12  
13  
        if(e.shiftKey) {
14  
            var start = $chkboxes.index(this);
15  
            var end = $chkboxes.index(lastChecked);
16  
17  
            $chkboxes.slice(Math.min(start,end), Math.max(start,end)+ 1).prop('checked', lastChecked.checked);
18  
19  
        }
20  
21  
        lastChecked = this;
22  
    });
23  
});]]);
24  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1008423
Snippet name: hCheckBoxMultiSelect - requires checkboxes to have class .chkbox
Eternal ID of this version: #1008423/3
Text MD5: 27f737fdc89e34b4e16a5e01c0d0481e
Author: stefan
Category: javax / html
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-11-17 13:54:30
Source code size: 581 bytes / 24 lines
Pitched / IR pitched: No / No
Views / Downloads: 534 / 554
Version history: 2 change(s)
Referenced in: [show references]