0
是否可以使用多選框將項目提交到貝寶購物車?我目前有一個JavaScript代碼,它循環選項,將它們附加到我的表單中,然後提交表單。但是隻有最後一個項目正在提交。在PayPal購物車中創建多個選項選項框
下面是代碼:
function getValues() {
var os0 = document.getElementById("os0");
var options = os0 && os0.options;
var price = 0;
for (i=0; i < options.length; i++) {
if(options[i].selected) {
switch(i) {
case 2:
case 4:
case 7:
case 8:
price = "30.00";
break;
case 0:
case 1:
case 3:
case 5:
case 6:
price ="25.00";
break;
default:
price ="25.00";
break;
}
$("#singleDungeon").append('<input type="hidden" name="option_select'+i+'" value="'+options[i].value+'"/>');
$("#singleDungeon").append('<input type="hidden" name="option_amount'+i+'" value="'+price+'"/>');
}
}
document.getElementById('singleDungeon').submit();
return true;
}
</script>
任何瞭解被理解。
謝謝!