What is the best method in jQuery to add an additional row to a table as the last row?
Is this acceptable?
$(\'#myTable\').append(\'
-
I Guess i have done in my project , here it is:
html
<%= form_for (@replication) do |f| %>
<%= f.label :SR_NO %>
<%= f.text_field :sr_no , :id => "txt_RegionName" %>
<%= f.label :Particular %>
<%= f.text_area :particular , :id => "txt_Region" %>
<%= f.label :Unit %>
<%= f.text_field :unit ,:id => "txt_Regio" %>
<%= f.label :Required_Quantity %>
<%= f.text_field :quantity ,:id => "txt_Regi" %>
<% end %>
SR_NO
Item Name
Particular
Cost
js
$(document).ready(function() {
$('#submit').prop('disabled', true);
$('#btn_AddToList').click(function () {
$('#submit').prop('disabled', true);
var val = $('#txt_RegionName').val();
var val2 = $('#txt_Region').val();
var val3 = $('#txt_Regio').val();
var val4 = $('#txt_Regi').val();
$('#lst_Regions').append('' + val + ' ' + '' + val2 + ' ' + '' + val3 + ' ' + '' + val4 + ' ');
$('#txt_RegionName').val('').focus();
$('#txt_Region').val('');
$('#txt_Regio').val('');
$('#txt_Regi').val('');
$('#btn_AddToList1').click(function () {
$('#submit').prop('disabled', false).addclass('btn btn-warning');
});
});
});
- 热议问题