0

我想根据单选按钮选择自动更新产品价格

http://demo.wdsindia.com/yossi/index.php?route=product/product&path=18&product_id=59当我点击 14K、18K 的单选按钮但错误的价格发生变化时。

与主要价格相同的14K option价格add $50

和主要价格的18K option价格add $100

但问题是当我选择任何选项时,它会增加 100 美元的主要价格。

这是我用来更改值的 jQuery

<script type="text/javascript">
$(document).ready(function() {
   $('.option').change(function() {
   var OriginalPrice = $('#thisIsOriginal').text();
   var OriginalCurrency = OriginalPrice.substring(0, 1);
   OriginalPrice = OriginalPrice.substring(1);

   var newPriceValue = $('.option :selected').text();
   var position1 = newPriceValue.indexOf("(");
   var position2 = newPriceValue.indexOf(")");
   position1 = position1+3;
   var finalPriceValue = newPriceValue.substring(position1, position2);
   if(newPriceValue.indexOf('.') == -1)
   {
    finalPriceValue = "0";
   }
   finalPriceValue = parseFloat(finalPriceValue) + parseFloat(OriginalPrice);
   finalPriceValue = finalPriceValue.toFixed(2);

   $('#priceUpdate').text(OriginalCurrency + finalPriceValue);
   });
});
</script>

提前致谢

4

0 回答 0