変更(jQuery)JSを含むコードを追跡して行われた変更についてチェックボックスやテイストのドロップダウンリストを更新価格

StackOverflow https://stackoverflow.com/questions/1881824

質問

いコードにjavascriptを使用していjQuery計算プラグインからダウンロードできます リンクテキストをドキュメント).のであり、私のようなショッピングカート形式につ価格のセキュリティ更新プログラムを適に数量を入力します。形としてテキストボックスを受け入れる番号のことを指します。この量が入力-変更、価格の更新と同時に、オールシーズンも更新しました。現在、でき作業テキストボックスに入力します。こういうことができるように使用チェックボックスのチェックとドロップダウンリストを書いていJSのコードを更新価格の合計に表示することをお勧めしが瞬時にでもいる場合、現在の既存のテキストボックス).やってみると自分のlocalhostもって解散することにな現在の機能または更新されたコードだけでは動作しないにチェックボックスのチェックとドロップダウンリストが表示されます。

のであり、私はこれまでには:

 <script src="js/jquery-1.3.2.min.js" type="text/javascript"></script>
<script src="js/jquery.calculation.js" type="text/javascript"></script>


<SCRIPT type="text/javascript">
var bIsFirebugReady = (!!window.console && !!window.console.log);

$(document).ready(
    function (){
        // update the plug-in version
        $("#idPluginVersion").text($.Calculation.version);


        // bind the recalc function to the quantity fields
        $("input[name^=qty_item_]").bind("keyup", recalc);
        // run the calculation function now
        recalc();

        // automatically update the "#totalSum" field every time
        // the values are changes via the keyup event
        $("input[name^=sum]").sum("keyup", "#totalSum");

        // automatically update the "#totalAvg" field every time
        // the values are changes via the keyup event
        $("input[name^=avg]").avg({
            bind:"keyup"
            , selector: "#totalAvg"
            // if an invalid character is found, change the background color
            , onParseError: function(){
                this.css("backgroundColor", "#cc0000")
            }
            // if the error has been cleared, reset the bgcolor
            , onParseClear: function (){
                this.css("backgroundColor", "");
            }
        });

        // automatically update the "#minNumber" field every time
        // the values are changes via the keyup event
        $("input[name^=min]").min("keyup", "#numberMin");

        // automatically update the "#minNumber" field every time
        // the values are changes via the keyup event
        $("input[name^=max]").max("keyup", {
            selector: "#numberMax"
            , oncalc: function (value, options){
                // you can use this to format the value
                $(options.selector).val(value);
            }
        });

        // this calculates the sum for some text nodes
        $("#idTotalTextSum").click(
            function (){
                // get the sum of the elements
                var sum = $(".textSum").sum();

                // update the total
                $("#totalTextSum").text("$" + sum.toString());
            }
        );

        // this calculates the average for some text nodes
        $("#idTotalTextAvg").click(
            function (){
                // get the average of the elements
                var avg = $(".textAvg").avg();

                // update the total
                $("#totalTextAvg").text(avg.toString());
            }
        );
    }
);

function recalc(){
    $("[id^=total_item]").calc(
        // the equation to use for the calculation
        "qty * price",
        // define the variables used in the equation, these can be a jQuery object
        {
            qty: $("input[name^=qty_item_]"), 
            price: $("[id^=price_item_]"),

        },
        // define the formatting callback, the results of the calculation are passed to this function
        function (s){
            // return the number as a dollar amount
            return "$" + s.toFixed(2);
        },
        // define the finish callback, this runs after the calculation has been complete
        function ($this){
            // sum the total of the $("[id^=total_item]") selector
            var sum = $this.sum();

            $("#grandTotal").text(
                // round the results to 2 digits
                "$" + sum.toFixed(2)
            );
        }
    );
}
</SCRIPT> 



<form name="form1" method="post" action="">

<div id="formContent">

  <P id="ex-sum">
  <table width="500">
                <COL style="width: 50px;">
                <COL>
                <COL style="width: 60px;">
                <COL style="width: 110px;">
                <tbody><tr>
                    <th width="179">
                        Qty
                    </th>
                    <th width="164" align="left">
                        Product
                    </th>
                    <th width="72">
                        Price
                    </th>
                    <th width="65">
                        Total
                    </th>
                </tr>
                <tr>
                    <td align="center">
                        <INPUT name="qty_item_1" type="text" class="input" id="qty_item_1" value="1" size="5">
                  </td>
                    <td>Table</td>
                    <td align="center" id="price_item_1">
                        $150
                    </td>
                    <td align="center" id="total_item_1">$</td>
                </tr>
                <tr>
                    <td align="center">
                        <INPUT name="qty_item_2" type="text" class="input" id="qty_item_2" size="5">
                  </td>
                    <td>
                        Pencil</td>
                    <td align="center" id="price_item_2">
                        $100</td>
                    <td align="center" id="total_item_2">$</td>
                </tr>
                <tr>
                    <td align="center">
                        <INPUT name="toys" type="checkbox" id="toys" value="1">
              </td>
                  <td>
                        Toys</td>
                    <td align="center" id="price_item_3">
                        $50</td>
                    <td align="center" id="total_item_3">$</td>
                </tr>  

              <tr>
                    <td align="center"><select name="books" id="books">
                      <option selected="selected">Select an option</option>
                      <option value="1">Book1</option>
                      <option value="1">Book2</option>
                      <option value="1">Book3</option>
                    </select></td>
                  <td>
                        Books</td>
                    <td align="center" id="price_item_3">
                        $10</td>
                    <td align="center" id="total_item_3">$</td>
                </tr>

                <tr>
                    <td colspan="3" align="right">
                        <STRONG>Grand Total:</STRONG>
                    </td>
                    <td align="center" id="grandTotal">$</td>
                </tr>
            </tbody></table>
</div>

</form>

またしていき、上記の形式コード、テーブルが用いられています。直しとかは出来ないんですか達成のた思いを使わずにテーブル?

ございます。

役に立ちましたか?

解決

ない答えになります。か注意しない場合はコメントとなります。

っているような気がするのだったコピーペーストの実質解するというこの計算プラグインです。やりたいんです。

ほんの数例

  • し複数の機能(最小、最大、平均)を使わないとする要素の表示値にも足りない。

  • 計算コードが設定されていチェック inputsの name属性から始ま qty_item_checkboxselect て全く異なる名前の属性。

  • の再計算を主に行き、 keyup イベントを明確にな火 checkboxselect ない限り、ユーザのキーボードの代わりにマウスで選択の値

  • まいなかったのでしょうかするとのことです。 jQueryプラグインの分野 この計算プラグインのホームページ状態を必要とするので利用したい場合は入力から text


ができcatched私が自分とチームにとって良いものか簡単な作業のデモページの都合のコードです。

http://jsbin.com/asepe3

がんについての説明の発もチェ(だけを許可するといったように正の整数)の不足やその他のもの。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top