on select pass 2 values

Solutions on MaxInterview for on select pass 2 values by the best coders in the world

showing results for - "on select pass 2 values"
Simone
03 Oct 2017
1<select>
2	<option data-mrp="1" data-price="2" value="x" >x</option>
3</select>
4
5<script type="text/javascript" src="assets/assets/jquery-1.11.0.js"></script>
6<script type="text/javascript">
7   var basePrice = 0;
8   var mrpPrice = 0;
9      $(".calculate<?= $p_id; ?>").change(function () {
10             newPrice = basePrice;
11             newmrpPrice = mrpPrice;
12             $(".calculate<?= $p_id; ?> option:selected").each(function () {
13                      newPrice += parseFloat($(this).data('price'));
14                      newmrpPrice += parseFloat($(this).data('mrp'));
15                      console.log(typeof newPrice);
16                      console.log(typeof newmrpPrice);
17             });
18             newPrice = newPrice.toFixed(0);
19             newmrpPrice = newmrpPrice.toFixed(0);
20             $("#item-price<?= $p_id; ?>").html(newPrice);
21             $("#mrp<?= $p_id; ?>").html(newmrpPrice);
22       });
23</script>