2011-02-15 36 views
0

這裏是我的網站http://iadprint.com/products?product=product%201選擇不計算難以看到,如果變量設置

當你選擇一個下拉屬性19k價格值的變化。但是當你選擇其他選擇時,什麼都不會發生。如果你在源頭上查看底部是我放的js。假設發生的情況是每次選擇一個選擇時,該值累計到總變量並顯示在定價範圍內。但我不明白爲什麼它不起作用。變量被分配但沒有計算髮生。任何人都可以看到我無法看到?這裏

感謝

PS是JS

  var woattribute19k_price; 
      var woattribute2_price; 
      var woattribute3_price; 
      var woattribute4_price; 
      var woattribute5_price; 












    $(document).ready(function() { 



     $("#attribute19k").change(function() 
     { 
      hash = $("#attribute19k").val(); 

      $.get("ajax.php", { id: hash }, 

       function(out) 
       { 
        woattribute19k_price = out.price; 
        displayPrice(); 

       }, "json"); 

      }); 

     $("#attribute2").change(function() 
     { 
      hash = $("#attribute2").val(); 

      $.get("ajax.php", { id: hash }, 

       function(out) 
       { 
        woattribute2_price = out.price; 
        displayPrice(); 

       }, "json"); 

      }); 

     $("#attribute3").change(function() 
     { 
      hash = $("#attribute3").val(); 

      $.get("ajax.php", { id: hash }, 

       function(out) 
       { 
        woattribute3_price = out.price; 
        displayPrice(); 

       }, "json"); 

      }); 

     $("#attribute4").change(function() 
     { 
      hash = $("#attribute4").val(); 

      $.get("ajax.php", { id: hash }, 

       function(out) 
       { 
        woattribute4_price = out.price; 
        displayPrice(); 

       }, "json"); 

      }); 

     $("#attribute5").change(function() 
     { 
      hash = $("#attribute5").val(); 

      $.get("ajax.php", { id: hash }, 

       function(out) 
       { 
        woattribute5_price = out.price; 
        displayPrice(); 

       }, "json"); 

      }); 



}); 






    function displayPrice() 
    { 
     var total = 0; 


     var qattribute19k = parseFloat((woattribute19k_price != null) ? woattribute19k_price : 0); 
     total = parseFloat(total + qattribute19k).toFixed(2); 



     var qattribute2 = parseFloat((woattribute2_price != null) ? woattribute2_price : 0); 
     total = parseFloat(total + qattribute2).toFixed(2); 



     var qattribute3 = parseFloat((woattribute3_price != null) ? woattribute3_price : 0); 
     total = parseFloat(total + qattribute3).toFixed(2); 



     var qattribute4 = parseFloat((woattribute4_price != null) ? woattribute4_price : 0); 
     total = parseFloat(total + qattribute4).toFixed(2); 



     var qattribute5 = parseFloat((woattribute5_price != null) ? woattribute5_price : 0); 
     total = parseFloat(total + qattribute5).toFixed(2); 




    $("#pricing span").text('$' + total); 
    } 
+0

年底請把你想知道關於這個問題的JS。 – 2011-02-15 07:43:22

回答

0

你必須使用toFixed只在displayPrice