dude
dude

Reputation: 4982

Is it possible to edit a table row using jquery

code

<td name="outwardQtyzzz"  align="left" valign="middle" bgcolor="#FFFFFF" class="rows"> <?=$row->outward;?> </td>

or

<td name="outwardQtyzzz"  align="left" valign="middle" bgcolor="#FFFFFF" class="rows"><input name="outwardQtyUpdated" type="hidden" value="" /> <?=$row->outward;?> </td>

jquery

    var quantity=$("[name=outwardQtyzz]").val($(this).closest('tr').find('td:eq(3)').text());

I just want to know how to edit a tr in a table using jquery and fetch the edit tr value,by the above jquery i can fetch the value of the tr before editing but after editing i am not able to fetch it using jquery

Upvotes: 0

Views: 537

Answers (2)

Mitesh
Mitesh

Reputation: 1

yes ...u can edit using .append(),.after(),.before() methods.. Here m putting 1 example...

$('#tr').after($(' <input type="text"  style="width:40px;" id="setUnitName"/>'));

where '#tr' is table row id,after which u can add textbox using above code,try after(),.before() as well..

Upvotes: 0

Manuel van Rijn
Manuel van Rijn

Reputation: 10315

Alright based on you're comment I think you want to get the value after you lose the focus of the input.

$("td.rows input").blur(function() {
  var quantity = $(this).val();
});

// or as of jQuery version 1.7
$("td.rows input").on('blur', function() {
  var quantity = $(this).val();
});

Upvotes: 1

Related Questions