I have a list of checkboxes in Twitter Bootstrap in the following format:
<form method='post' class="form-horizontal" id="myform">
<input type="checkbox" attr1="2" attr2="4" prodname="product1"> product1
<input type="checkbox" attr1="5" attr2="1" prodname="product2"> product2
<input type="checkbox" attr1="1" attr2="7" prodname="product3"> product3
....
....
<button type="submit" class="btn btn-success pull-right">Calculate</button>
</form>
The user will choose some of the products (not all of them) and click the submit button to see the result in base of the following formula:
finalvalue = sum_of_attr1/total_num_checked + 10*best_prod_attr1 - best_prod_attr2
This means that I have to find the sum of all the attr1 of the checked boxes and how many are checked and then try every checked box to see which of them will give the maximum value. Then I will update a div with the final value and the prodname
of the best product.
I don't want to do this in server-side and I want to try it with Javascript/JQuery. Any thoughts?