下面的函数假设给我一个警报,询问我是否确定要删除选定的用户。但是,警报给了我所有用户的列表,而不是选定的用户。
var user, group, strHTMLSiteUsers, strHTMLSiteGroups, strHTMLAvailable, strHTMLAssigned, arrOptionsAssigned, arrGroups, arrUsers, intOpts, booMatch, booErr;
$(document).ready(function(){
user = $('#my_SiteUsers');
group = $('#my_SiteGroups');
groupsAssigned = $("#my_SPGroupsAssigned").html("Cats");
groupAvailable = $("#my_SPGroupsAvailable").html("Cats");
userAssigned = $("#my_SPUsersAssigned").html("Cats");
userAvailable = $("#my_SPUsersAvailable").html("Cats");
$("button").click(function() { return false; });
populateUsers();
populateGroups();
});
if(user.val()!= null){
var removeConfirm = confirm("You are about to delete "+user.text()+" from SharePoint. Are you sure?");
if(removeConfirm){
$().SPServices({
operation:"RemoveUserFromWeb",
userLoginName: user.val(),
async:true,
completefunc: function (xData,Status){
alert(user.text()+ " deleted succesfully");
}
});
}
}else{
alert("Please select a user");
}
}
HTML:
<select id="my_SiteUsers" style="width:200px;" onchange="RefreshGroupLists()">
<option value='default' disabled="disabled">Select a user</option>
</select>