Skip to content

Instantly share code, notes, and snippets.

@ScottRadcliff
Created May 7, 2010 14:26
Show Gist options
  • Save ScottRadcliff/393482 to your computer and use it in GitHub Desktop.
Save ScottRadcliff/393482 to your computer and use it in GitHub Desktop.
// Grabs the size selected and adds it to the total
$("select[name = 'sizes[]']").click(function(){
var sizes = $("select[name = 'sizes[]']");
var counter = 0;
for (var i=0; i < sizes.length; i++) {
counter = Number(counter) + Number(sizes[i].value);
};
sub_total = counter;
$("#sub_total").text("$" + sub_total + ".00");
});
// Grabs the size selected and adds it to the total
$("select").change(function(){
var sizes = $("select[name = 'sizes[]']");
var counter = 0;
for (var i=0; i < sizes.length; i++) {
counter = Number(counter) + Number(sizes[i].value);
};
sub_total = counter;
$("#sub_total").text("$" + sub_total + ".00");
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment