我有两个变量user
并group
声明。当我运行该函数removeGroupFromSite()
时,它应该提醒我说请选择一个组,但变量返回为null。我认为这是因为它获得了选择的价值而不是选择的选项?如何在这些变量中获取所选选项的值?
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");
groupAvailable = $("#my_SPGroupsAvailable");
userAssigned = $("#my_SPUsersAssigned").html("");
userAvailable = $("#my_SPUsersAvailable").html("");
$("button").click(function() { return false; });
populateUsers();
populateGroups();
});
function removeGroupFromSite(){
//check if default group selected
alert('cp'+group.val());
if(group.val() !== "default"){
var removeConfirm = confirm("Are you sure you want to delete group: " + group.val());
if(removeConfirm){
$().SPServices({
operation:"RemoveGroup",
groupName: group,
async:true,
completefunc: function (xData,Status){
alert(group + " succesfully deleted");
}
});
}
}else{
alert("Please select a group");
}
}
HTML
<select id="my_SiteGroups" style="width:200px;" onchange="RefreshUserLists()">
<option value='default' disabled="disabled">Select a group</option>
</select>