This script extracts data from check boxes in order to determine the information a form sends to PayPal. PayPal only accepts a cart without any gaps; however, this script counts unchecked boxes in the index which makes the cart invalid ("item_name_1", "item_name_3", "item_name_7"). How do I make it so that the script generates a gapless succession of numbers ("item_name_1", "item_name_2", "item_name_3")?
function updateCart(form) {
var cart = "";
var P = $('#P');
for (var i = 0; i < document.getElementById('sList').P.length; i++) {
if (document.getElementById('sList').P[i].checked)
cart += '
'
}
if (cart == "") {
alert("Please select products")
} else alert(cart);
$('#cart_items').html("" + cart);
return false;
}
JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)