BootStrapシャトルボックス
3953 ワード
Title
$(function(){
var j_all_area = $("#sel_all_area"), j_selected_areas = $("#sel_selected_areas");
$("#btn_select_all_area").click(function(){
var selectedAreaArray = [];
j_all_area.find("option").each(function(i){
selectedAreaArray[i] = $(this).val();
$(this).appendTo(j_selected_areas);
});
doSubmit('add',selectedAreaArray.toString());
return false;
});
$("#btn_choose_selected_area").click(function(){
var selectedAreaArray = [];
j_all_area.find("option:selected").each(function(i){
selectedAreaArray[i] = $(this).val();
$(this).appendTo(j_selected_areas);
});
doSubmit('add',selectedAreaArray.toString());
return false;
});
$("#btn_remove_selected_area").click(function(){
var selectedAreaArray = [];
j_selected_areas.find("option:selected").each(function(i){
selectedAreaArray[i] = $(this).val();
$(this).appendTo(j_all_area);
});
doSubmit('del',selectedAreaArray.toString());
return false;
});
$("#btn_remove_all_area").click(function(){
var selectedAreaArray = [];
j_selected_areas.find("option").each(function(i){
selectedAreaArray[i] = $(this).val();
$(this).appendTo(j_all_area);
});
doSubmit('del',selectedAreaArray.toString());
return false;
});
})
function doSubmit(select_type,roleids){
var userid = $("#userid").val();
$.post("doroledefine",{userid:userid,roleids:roleids,type:select_type},function(result){
if (result == "error") {
layer.msg(' !', {
icon: 2
})
}else{
initParams();
layer.msg(' !', {
icon: 1
})
}
});
}