2012-02-24 27 views
0

:プラグイン ホームページ:LinkJQuery:計算プラグインが合計価格に計算されません

:javascriptの

$("[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/