0

私は4列のグリッドを持っています:

  1. 名前
  2. 料金
  3. 総費用

これらの 4 ではNameCostデータベースから取得されQuantity、テキスト フィールドです。テキスト フィールドに値を入力すると、Java に移動して を実行し、データQuantity * Costを入力するtotalcost必要があります。これが私の要件です。このために、次のコードを使用しています。

私のjspには、次のようなコンテナがあります。

<div id="search-results-list" class="green-results-list" style="height: 150px; width: 697px;">
</div>
Handler.setupGrid();

setupGrid の js ファイルには、次のコード行があります。

setupGrid : function() {

        $('.green-results-list').html('');
        $.post('note.json', 'action=get-grid-data', function(obj) {
            var data = obj.result.data;
            if(data !== undefined){
                if(data.length>0) {
                    var rowstr = '';
                    for(var x=0;x<data.length;x=x+1) {
                        rowstr=rowstr+'<div class="ui-content report-content">';
                        rowstr=rowstr+'<div class="report-body" style="width: 697px;height: 50px;">';
                        rowstr=rowstr+'<div class="report-body-column2 centered" style="height: 41px; width: 150px">'+data[x].name+'</div>';
                        rowstr=rowstr+'<div class="report-body-column2 centered" style="height: 41px; width: 150px">'+'<input type = "text"  class="quantity" size=10px>'+'</div>';
                        rowstr=rowstr+'<div class="report-body-column2 centered" style="height: 41px; width: 150px">'+data[x].cost+'</div>';
                        rowstr=rowstr+'<div class="report-body-column2 centered" style="height: 41px; width: 150px">'+data[x].totalCost+'</div>';
                        rowstr=rowstr+'</div></div>';
                        }
                    $('.green-results-list').append(rowstr);

                } else {
                $('.green-results-list').html('<div class="success-msg">No Data Exist.</div>');
            }
        }else {
            $('.green-results-list').html('<div class="success-msg">No Data Exist.</div>');
        }
    });

    }

テキストフィールドに値を入力すると、以下のコード行を使用してテキストフィールドの値を取得しています:

$('.quantity').live("blur",function(){
    var data = $(this).val();
    alert(data);
 });

これを使用して、テキスト フィールドの値を取得しています。しかし、私の問題は、totalCostその特定の行のテキスト フィールドに値を入力するときだけ有効にする必要があることです。

これどうやってするの?どんな助けでも大歓迎です。

ありがとう、私の下手な英語でごめんなさい。私の問題を理解していただければ幸いです。

4

1 に答える 1