Calculation plugin with Multiple Dropdown field
I'm using the Calculation plugin with regular dropdown fields, but I need a Multiple Select field. Changing the Select element to Multiple is not enough - it stops working altogether. I need to add the various options that are selected and send them to my function, or have the function add them - not sure how to proceed.
Can anyone help?
Thanks
I'm binding my dropdown elements to the function with "change" - this solution courtesy of oxodesign
- $("input[id^=item_]").bind("keyup", myFunction);
- $("select[id^=item_]").bind("change", myFunction);
This is the function:
- $("div[id^=item_sum_]").calc(
- "(sum / 100 * vat)",
- {
- vat: $("select[id^=item_vat_]"),
- sum: $("div[id^=item_sum_]")
- },
- function (s){
- return 'kr ' + s.toFixed(2);
- },
-
- function ($this){
- var sum = $this.sum();
- $("#items_sum_total").text(
- 'kr ' + sum.toFixed(2)
- );
- }
- );
And here is the Select element:
- <select class="item max" name="item[1][vat]" id="item_vat_1">
- <option selected="" value="25">25 %</option>
- <option value="14">14 %</option>
- <option value="8">08 %</option>
- <option value="0">0 %</option>
- </select>