2012-02-24 3 views
0

: 플러그인 홈페이지 : Link.JQuery : 계산 플러그인이 총 가격으로 계산되지 않음

:

$("[id^=total_price_ht]").calc(
    // the equation to use for the calculation 
    "qty * price", 
    { 
     qty: $("[id^=unit_quantity_]"), 
     price: $("[id^=unit_price_ht_]") 
    }, 
    function (s){ 
     // return the number as a dollar amount 
     return "$" + s.toFixed(2); 
    } 
); 

자바 스크립트 : HTML

<tr id="lines[0]"> 
    <td> 
    <input id="0" type="checkbox" class="hiddenCheckbox"> 
    <label for="0" class="prettyCheckbox checkbox list"><span class="holderWrap" style="width: 18px; height: 19px; "><span class="holder" style="width: 18px; "></span></span></label> 
    </td> 
    <td> 
    <input class="required" name="lines[0][title]" placeholder="Title" type="text"> 
    </td> 
    <td> 
    <input name="lines[0][description]" placeholder="Description" type="text"> 
    </td> 
    <td> 
    <input class="required" id="unit_quantity_0" name="lines[0][quantity]" placeholder="Quantité" type="text" value="0,00"> 
    </td> 
    <td> 
    <input class="required" id="unit_price_ht_0" name="lines[0][unit_price_ht]" placeholder="Prix unit. HT" type="text" value="0,00"> 
    </td> 
    <td class="price" id="total_price_ht_0">$0.00</td> 
</tr> 

페이지가로드되면, 나는 total_price_ht 필드에 "$ 0.00 '볼 수 있지만이 경우 변경되지 않는 값이다 수량 또는 가격을 변경합니다.

무엇이 잘못 되었나요? 감사합니다.

+0

당신이 생성 된 HTML을 게시 할 수 있을까요? –

+0

@AndrewWhitaker 생성 된 HTML을 게시했습니다. 감사. – Laura

+0

감사합니다 - 사용중인 플러그인입니까? http://www.pengoworks.com/workshop/jquery/calculation/calculation.plugin.htm –

답변

0

나는 당신이 총 다시 계산 할 때마다 calc 플러그인을 호출 할 필요가 있다고 생각 :

$("[id^='unit_quantity_'], [id^='unit_price_ht_']").keyup(recalc); 


function recalc() { 

    $("[id^='total_price_ht']").calc(
    // the equation to use for the calculation 
    "qty * price", { 
     bind: "keyup", 
     qty: $("[id^='unit_quantity_']"), 
     price: $("[id^='unit_price_ht_']") 
    }, function(s) { 
     // return the number as a dollar amount 
     return "$" + s.toFixed(2); 
    }); 
} 

recalc(); 

예 :http://jsfiddle.net/upEZW/

관련 문제