question

PolachanPaily-2805 avatar image
0 Votes"
PolachanPaily-2805 asked 35366280 answered

How can make empty in each column while adding new rows in a table

0


I have a table with the column customer name, Address, Salary etc. But when I add the new row in the table using button btnUpdate , the previous row column value would be placed in the corresponding column of the new row . How can I make it empty column in the new row while adding it . Here is the code attached

124711-codesample.txt



dotnet-aspnet-core-mvc
codesample.txt (1.2 KiB)
· 4
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

You code specifically clones the first row which is not good a design approach because the code creates invalid markup. Simply take the time and care to design and write a JavaScript application that adds a new HTML table row. the code is not that complicated.

You've written this type of code in your other threads so it is not clear why you are struggling now.

0 Votes 0 ·

Hi @PolachanPaily-2805 , how about appending html content directly? Like code below:

 var html = "<tr>"+
                             "<td><input class='form-control datepicker w-100' name='StudentName' type='text' value='' /></td>"+
                             "<td><input class='form-control datepicker w-100' name='Address' type='text' value='' /></td>"+
                             "<td><input class='form-control  w-100' name='Salary' type='number' value='' /></td>"+
                             "</tr>";
                 $("tbody").append(html);
0 Votes 0 ·

II have given as you said as given below, not working

function AddNew() {
var newRow = $("#tblEntry tbody tr").first().clone();
/var row = $("tbody").append(newRow);/
$("tbody").append(html);
netHrs.val("");
}

0 Votes 0 ·

Hi @PolachanPaily-2805 , the attachment is my newly created asp.net core 3.1 mvc project -- home index.cshtml file, and it really work in my side but I'm not sure if I misunderstood in some place. This is my test result124897-testcode.txt

124993-image.png


0 Votes 0 ·
testcode.txt (1.4 KiB)
image.png (23.9 KiB)

1 Answer

35366280 avatar image
0 Votes"
35366280 answered

the first row which is not good a design approach because the code creates invalid markup. Simply take the time and care to design and write a JavaScript application that adds a new HTML table row. the code is not that complicated

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.