I have rephrased this question, I will try to be more objective. I have this field in the form:
Wherethecodeareathatcomputesisthis:
$("div#molhos :checkbox:checked" ).each(function() {
sub += $( this ).val() * $( this ).parent().find("select").val();
}); // each molhos
So far so good, what I need is that at the end of the calculation it subtracts ONE, example: If the user chooses THREE SAUCE 1 and TWO SAUCE 3 the total will be 5 sauces, correct? I would give $ 7.50, but I want the result to always be with LESS ONE, it would be the right amount $ 6.00.
The rule would be to choose ONE sauce, it will be free, from the second one we will charge.
I do not know if it helps, but it goes further information from the code: This is the top:
var str = "";
var id = "";
var sub = 0.00;
var taxa = 0;
var taxadeentrega = total - taxa;
var total = 0.00;
var qcount = 0;
var scount = 0;
var opc = 0;
var options = "";
for (i=1; i<21; i++){
options += "<option value='" + i + "'>" + i + "</option>";
}
This is another area of the code that Sauce is mentioned:
<!--MOLHOS-->
$( "div#molhos :checkbox:checked" ).each(function() {
var sel = $(this).parent().children("select").val();
str = str + $(this).parent().children("strong").text() + ": R$ " + $(this).val().replace(".", ",") + " x " + sel + " = R$ " + (($(this).val() * sel).toFixed(2)).replace(".", ",") + "<br>";
})
$('input[name=molhos]').val(str);
str = "";
But I believe that the important part to create this rule is the first of this post! I think it's the if rule, but I can not do it, I've tried everything !!