Form Calculator Script Base Price Not Loading OnLoad

前端 未结 1 751
故里飘歌
故里飘歌 2021-01-29 09:39

I have a calulcator in my form to calculate my dropdown options choices.

$(function() {
  $(\"select.calculate\").on(\"change\", calc);
  $(\"input[type=checkbo         


        
1条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-29 09:57

     var basePrice = 60; 
     $(document).ready(function() {
     $("select.calculate").on("change", calc);
     $("input[type=checkbox].calculate").on("click", calc);
     $("#item-price").html(basePrice);
     $("#item_price_val").val(basePrice);
    });
    function calc() {
    newPrice = basePrice;
    $("select.calculate option:selected,input[type=checkbox].calculate:checked").each(function() {
      newPrice += parseInt($(this).data('price'), 10);
    });
    newPrice = newPrice.toFixed(2);
    $("#item-price").html(newPrice);
    $("#item_price_val").val(newPrice);
    }
    

    Please Use an updated version of your code.

    0 讨论(0)
提交回复
热议问题