I have the following html
<input type="checkbox" name="array[0][count]" value="1"/>
<input type="hidden" data-price="50" name="array[0][id]" value="1"/>
<input type="checkbox" name="array[1][count]" value="5"/>
<input type="hidden" data-price="20" name="array[1][id]" value="2"/>
.....
I want to calculate the sum of data-price using jQuery with the formula
foreach extra {
price += extra[id][data-price] * extra[count]
}
//not actual code, just a representation of the result needed
So far I was able to collect all the inputs using
$('input[name^="array"]').each(function() {
console.log($(this));
});
But I have no idea how to proceed further. Any help appreciated. If you can point me to a better way to structure the html array, I'm ok with that.
:checkedinputs, each multiplied by the correspondingcount