我有一个删除按钮:
我试图首先确定是否选择了一个站点,如果选择了一个站点,我需要确定是否选择了一个或多个列表项,如果是,则继续删除这些项。
我的 if 语句不断返回“您必须首先选择您的列表”,即使它们已被选中。
function deleteList(){
if(!siteUrl){
alert("You must first select a site");
return;
}else if (siteLists.selectedIndex == null){
alert('You must first select your list(s)');
return;
}else{
var arrList = siteLists.val();
var listIndex;
var removeConfirm = confirm("Are you sure you want to delete these lists?")
if(removeConfirm){
for(listIndex = 0; listIndex<arrList.length;listIndex++){
$().SPSservices({
operation: "DeleteList",
webUrl: siteUrl,
listName: arrList[listIndex],
completefunc: function(){
RefreshSiteList(siteUrl);
alert("Selected lists have been deleted");
}
});
}
}
}
}
HTML
<select id="web_siteLists" style="width:150px;height:150px;" multiple="multiple">
<option value="{041D004F-3BD7-41C2-BE02-F166A6970FDA}">Announcements</option>
<option value="{92E428BF-6F94-47D5-B9EF-446F62827749}">Calendar</option>
<option value="{F8F92E1D-4CF0-4E80-B037-1867BD8A35B2}">Links</option>
<option value="{1E0BD0DF-D4A0-4C27-8F3F-5E4AB4FAFBB4}">Master Page Gallery</option>
<option value="{DF86CAA5-B365-484D-8792-9771E10768E0}">Team List 3</option>
<option value="{5FD4247D-3C54-4D9A-8F0F-E4C374D966B0}">Team List 4</option>
<option value="{E7CBEC72-7A63-414A-8F3C-18579A3FC7D7}">Team List 5</option>
</select>