我有一個刪除按鈕選擇確定或更多列表項目已被選擇,如果是的話,繼續刪除這些項目。如果任何選項已在if語句
我的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>
你在哪裏實際上定義'siteLists' – scrappedcola
我有抓住元素待機功能:siteLists = $( '#web_siteLists');這是一個全球變量。否則我會得到一個未定義的。 – Batman
你是否選擇了dom準備好?如果沒有,它將不存在 – scrappedcola