Skip to content

Instantly share code, notes, and snippets.

@foxweb
Created December 2, 2009 18:56
Show Gist options
  • Save foxweb/247440 to your computer and use it in GitHub Desktop.
Save foxweb/247440 to your computer and use it in GitHub Desktop.
function checkRequiredPayments() {
$('input.payment_sum_field').each(function() {
if ($(this).hasClass("required")) {
var tr = $(this).parents("tr");
var checkbox = $("input[type=checkbox]:first", tr);
if (!checkbox.attr("checked")) {
checkbox.attr("checked", true);
}
var re = new RegExp("r_([0-9]+)");
var match = re.exec($(this).attr("class"));
if (match != null) {
var required_sum = match[1];
if ($(this).attr("value") * 1 <= required_sum) {
if ($('input.payment_check:checked').length > 0) {
$(this).attr("value", required_sum);
if ($('input.payment_check:checked').length > 1) {
$("div.required_payment:first").removeClass("hidden");
}
}
else {
var total = $("#order_total").html() * 1;
$(this).attr("value", total);
}
}
}
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment