MULTIPLE CHECKBOX SELECTION WITH SHIFT KEY PRESS
<script>
function checkboxClick(){
$(':checkbox').click(function(e){
if (e.shiftKey){
// Entered - When the user clicks the checkbox with shift key
shiftCheckBox = $(this).attr('id');
// salesforce id's having multiple ':' like 'dbpage:dbform:results:j_id173:5:selectStarredCalls'. So we need to split the unique number of the Id
// If HTML checkbox you dont need to split the id
var shiftCheckBoxID = shiftCheckBox.split(':');
var shiftCheckBoxIDPos = shiftCheckBoxID[shiftCheckBoxID.length-2];
shiftCheckBoxIDPos = parseInt(shiftCheckBoxIDPos);
var checkBoxClickID = checkBoxClick.split(':');
var checkBoxClickIDPos = checkBoxClickID[checkBoxClickID.length-2];
checkBoxClickIDPos = parseInt(checkBoxClickIDPos);
// checkboxIdsList - having id's of all checkboxes, When the checkboxes are created, at the time assign all the checkbox id's in this list
var checkboxIdsArray = checkboxIdsList;
if(shiftCheckBoxIDPos > checkBoxClickIDPos){
for(var i=0; i < checkboxIdsArray.length; i++){
var innerId = checkboxIdsArray[i];
var splitedInnerId= innerId.split(':');
var splitedInnerIdPos = splitedInnerId[splitedInnerId.length-2];
splitedInnerIdPos = parseInt(splitedInnerIdPos);
if(splitedInnerIdPos > checkBoxClickIDPos && splitedInnerIdPos < shiftCheckBoxIDPos ){
var inBetweenCheckBoxId = checkboxIdsArray[splitedInnerIdPos];
var test = inBetweenCheckBoxId ;
document.getElementById(test).checked = true;
}
}
}else{
for(var j=0; j < checkboxIdsArray.length; j++){
var innerId1 = checkboxIdsArray[j];
var splitedInnerId1= innerId1.split(':');
var splitedInnerIdPos1 = splitedInnerId1[splitedInnerId1.length-2];
splitedInnerIdPos1 = parseInt(splitedInnerIdPos1);
if(splitedInnerIdPos1 > shiftCheckBoxIDPos && splitedInnerIdPos1 < checkBoxClickIDPos ){
var inBetweenCheckBoxId1 = checkboxIdsArray[splitedInnerIdPos1];
var test1 = inBetweenCheckBoxId1 ;
document.getElementById(test1).checked = true;
}
}
}
}else{
// Id of last clicked checkbox id (Without shift key press )
checkBoxClick = $(this).attr('id');
}
});
}
</script>
<script>
function checkboxClick(){
$(':checkbox').click(function(e){
if (e.shiftKey){
// Entered - When the user clicks the checkbox with shift key
shiftCheckBox = $(this).attr('id');
// salesforce id's having multiple ':' like 'dbpage:dbform:results:j_id173:5:selectStarredCalls'. So we need to split the unique number of the Id
// If HTML checkbox you dont need to split the id
var shiftCheckBoxID = shiftCheckBox.split(':');
var shiftCheckBoxIDPos = shiftCheckBoxID[shiftCheckBoxID.length-2];
shiftCheckBoxIDPos = parseInt(shiftCheckBoxIDPos);
var checkBoxClickID = checkBoxClick.split(':');
var checkBoxClickIDPos = checkBoxClickID[checkBoxClickID.length-2];
checkBoxClickIDPos = parseInt(checkBoxClickIDPos);
// checkboxIdsList - having id's of all checkboxes, When the checkboxes are created, at the time assign all the checkbox id's in this list
var checkboxIdsArray = checkboxIdsList;
if(shiftCheckBoxIDPos > checkBoxClickIDPos){
for(var i=0; i < checkboxIdsArray.length; i++){
var innerId = checkboxIdsArray[i];
var splitedInnerId= innerId.split(':');
var splitedInnerIdPos = splitedInnerId[splitedInnerId.length-2];
splitedInnerIdPos = parseInt(splitedInnerIdPos);
if(splitedInnerIdPos > checkBoxClickIDPos && splitedInnerIdPos < shiftCheckBoxIDPos ){
var inBetweenCheckBoxId = checkboxIdsArray[splitedInnerIdPos];
var test = inBetweenCheckBoxId ;
document.getElementById(test).checked = true;
}
}
}else{
for(var j=0; j < checkboxIdsArray.length; j++){
var innerId1 = checkboxIdsArray[j];
var splitedInnerId1= innerId1.split(':');
var splitedInnerIdPos1 = splitedInnerId1[splitedInnerId1.length-2];
splitedInnerIdPos1 = parseInt(splitedInnerIdPos1);
if(splitedInnerIdPos1 > shiftCheckBoxIDPos && splitedInnerIdPos1 < checkBoxClickIDPos ){
var inBetweenCheckBoxId1 = checkboxIdsArray[splitedInnerIdPos1];
var test1 = inBetweenCheckBoxId1 ;
document.getElementById(test1).checked = true;
}
}
}
}else{
// Id of last clicked checkbox id (Without shift key press )
checkBoxClick = $(this).attr('id');
}
});
}
</script>
மிகவும் பயன் உள்ளதாக உள்ளது.
ReplyDelete