Answers for "select option multiple values html"

2

html select multiple

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdn.rawgit.com/harvesthq/chosen/gh-pages/chosen.jquery.min.js"></script>
<link href="https://cdn.rawgit.com/harvesthq/chosen/gh-pages/chosen.min.css" rel="stylesheet"/>

<form action="http://httpbin.org/post" method="post">
  <select data-placeholder="Begin typing a name to filter..." multiple class="chosen-select" name="test">
    <option value=""></option>
    <option>American Black Bear</option>
    <option>Asiatic Black Bear</option>
    <option>Brown Bear</option>
    <option>Giant Panda</option>
    <option>Sloth Bear</option>
    <option>Sun Bear</option>
    <option>Polar Bear</option>
    <option>Spectacled Bear</option>
  </select>
  <input type="submit">
</form>
Posted by: Guest on March-25-2021
0

on select pass 2 values

<select>
	<option data-mrp="1" data-price="2" value="x" >x</option>
</select>

<script type="text/javascript" src="assets/assets/jquery-1.11.0.js"></script>
<script type="text/javascript">
   var basePrice = 0;
   var mrpPrice = 0;
      $(".calculate<?= $p_id; ?>").change(function () {
             newPrice = basePrice;
             newmrpPrice = mrpPrice;
             $(".calculate<?= $p_id; ?> option:selected").each(function () {
                      newPrice += parseFloat($(this).data('price'));
                      newmrpPrice += parseFloat($(this).data('mrp'));
                      console.log(typeof newPrice);
                      console.log(typeof newmrpPrice);
             });
             newPrice = newPrice.toFixed(0);
             newmrpPrice = newmrpPrice.toFixed(0);
             $("#item-price<?= $p_id; ?>").html(newPrice);
             $("#mrp<?= $p_id; ?>").html(newmrpPrice);
       });
</script>
Posted by: Guest on December-04-2020

Code answers related to "select option multiple values html"

Browse Popular Code Answers by Language