0
我試圖從功能中的選擇框中刪除選定的選項。下面的代碼不起作用。我究竟做錯了什麼?我試圖從Javascript中的選擇框中刪除指定的選項
function removeItem(refundItem) {
itemToDelete = document.getElementById("yourStuff").options[refundItem].text;
inCart = document.getElementById("yourCart").rows.length;
for (i = 1; i <= inCart; i++) {
maybeRefund = document.getElementById("yourCart").rows[i].cells[0].innerHTML;
maybeRefund = maybeRefund.trim();
if (itemToDelete == maybeRefund) {
refundPrice = document.getElementById("yourCart").rows[i].cells[2].innerHTML;
document.getElementById("yourCart").deleteRow(i);
Money.value = Number(Money.value) + Number(refundPrice);
document.getElementById("yourCart").deleteRow(i);
document.getElementById("yourStuff").options.remove(refundItem);
// document.getElementById("yourStuff").options.remove(selectedIndex);
}
}
document.getElementById("yourStuff").selectedIndex = 0;
}