How to get the particular row id in jquery -


i have grid 4 columns:

  1. name
  2. quantity
  3. cost
  4. total cost

in these 4 name , cost come database , quantity text field. when enter value text field should go java , perform quantity * cost , populate totalcost .this requirement. using following code:

in jsp have container this:

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

and in js file in setupgrid have following lines of code.

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>');         }     });      } 

when enter value text field getting text field value using below lines of code:

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

using getting text field value. problem when enter value text field totalcost of particular row needs effected.

how can this? appreciated.

thank , sorry poor english. hope able understand problem.

you can find 'row' using closest() function example

var $row = $(this).closest("div"); 

upd:

and div's text using text() or html using html() functions

var text = $row.text(); var html = $tow.html(); 

i recommend learn basics first. example try jquery screencasts.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -