i have table , form 2 input fields.
once user type in input fields , click save...it goes table row.
now user types again , click save...it replaces old entries.
i add new row new text in input field user types before clicking save.
<table class="table table-bordered table1"> <thead> <tr class="info"> <td>id</td> <td>name</td> <td>access</td> <td>delete</td> <td>edit</td> </tr> </thead> <tbody> <tr class="info"> <td class="mac-id"> </td> <td class="nameofuser"> </td> <td class="access"> </td> <td class="btn-delete"><a href="#" class="trash-icon"> </a></td> <td class="btn-edit"><a href="#" class="edit-icon"> </a></td> </tr> </tbody> </table> </div> <div class="buttons"> <a href="#" class="btn btn-primary btn-new">new</a> <a href="#" class="btn btn-success btn-save">save</a> <a href="#" class="btn btn-warning btn-cancel">cancel</a> </div> </table>
jquery
$(".btn-save").click(function(e) { var macid = $("#mac-address").val(this); var nameofuser = $("#user-name").val(this); var access = $("#access option:selected").text(this); $(".table1 tr:last").after("<tr class='info'><td> </td><td></td><td></td><td></td><td></td></tr>"); });
it looks need add input values code:
$(".btn-save").click(function(e) { var macid = $("#mac-address").val(); var nameofuser = $("#user-name").val(); var access = $("#access option:selected").text(); $(".table1 tr:last").after("<tr class='info'><td>" + macid + "</td><td>" + nameofuser + "</td><td>" + access + "</td>" + "<td class='btn-delete'><a href='#' class='trash-icon'> </a></td>" + "<td class='btn-edit'><a href='#' class='edit-icon'> </a></td>"); });
errr, this
within code pointing save button. remove too.
Comments
Post a Comment