【发布时间】:2014-03-15 03:35:52
【问题描述】:
是否可以使用多选框将商品提交到贝宝购物车?我目前有一个 javascript 循环遍历选项,将它们附加到我的表单,然后提交表单。但是只有最后一个项目被提交。
代码如下:
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>
感谢任何见解。
谢谢!
【问题讨论】:
标签: paypal