Calculation plugin with Multiple Dropdown field

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

  1. $("input[id^=item_]").bind("keyup", myFunction);
  2. $("select[id^=item_]").bind("change", myFunction);

This is the function:

  1. $("div[id^=item_sum_]").calc(
  2.     "(sum / 100 * vat)",
  3.     {
  4.         vat: $("select[id^=item_vat_]"),
  5.         sum: $("div[id^=item_sum_]")
  6.     },
  7.     function (s){
  8.         return 'kr ' + s.toFixed(2);
  9.     },
  10.     
  11.     function ($this){
  12.         var sum = $this.sum();
  13.         $("#items_sum_total").text(
  14.             'kr ' + sum.toFixed(2)
  15.         );
  16.     }
  17. );

And here is the Select element:

  1. <select class="item max" name="item[1][vat]" id="item_vat_1">
  2.     <option selected="" value="25">25 %</option>
  3.     <option value="14">14 %</option>
  4.     <option value="8">08 %</option>
  5.     <option value="0">0 %</option>
  6. </select>