Is it possible to submit items to a paypal shopping cart using a multiple select box? I currently have a javascript in place that loops through the options, appends them to my form, and then submits the form. However only the last item is being submitted.
Here is the code:
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>
Any insight is appreciated.
Thanks!
Got it working. The shopping cart system will ignore items if not used with correct increments and syntax. So, changed the code to item_name_# and amount_#. Also, added a count value instead of using the index value. So it will be amount_1, amount_2, instead of amount_6, etc.