Hello,
i have a simple form that calculates the total of some checkboxes which works fine. Now, I need to offer a flat rate when 2 or more boxes are checked.
Example: 1 box = 100, 2 boxes or more = 175.
Finally, certain checkboxes must be exempt from the discount.
I am new to JS and just to get the form i currently have to work, took me forever, so please be gentle!
Here is my code:


<script type="text/javascript">
function calculate() {
var elems = document.forms['form1'].elements;
var total = 0;
for(var i=0;i<elems.length;i++) {
if (elems[i].checked) {total += +(elems[i].value);}
}
elems['total'].value = total;
}
</script>


boxes where 2 or more must = 175:

<input type="checkbox" name="checkbox_group_1[]" onclick="calculate()" value="100" title="Check here" />
<input type="checkbox" name="checkbox_group_2[]" onclick="calculate()" value="100" title="Check here" />
<input type="checkbox" name="checkbox_group_3[]" onclick="calculate()" value="100" title="Check here" />

exempt boxes:

<input type="checkbox" name="checkbox_group_4[]" onclick="calculate()" value="20" title="Check here" />
<input type="checkbox" name="checkbox_group_5[]" onclick="calculate()" value="20" title="Check here" />

thanks!