Skip to content Skip to sidebar Skip to footer

How Do I Add A Row Of Input Boxes, To An Existing Html Form Using Javascript

I have a form which displays rows from a database table and an update button with each row. I need to add a blank row on a button click (ADD ENTRY) exactly like the ones above in

Solution 1:

It may help you.

$(document).ready(function() {
    $('a').click(function() {
       $('#myTable tbody').append('<tr class="child"><td><input type="text"></td><td><input type="text"></td><td<input type="text"></td><td><input type="text"></td><td><input type="text"></td><td>submit</td></tr>');
    });
});
input{
  width:40px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<a href="javascript:void(0);">add new</a>
<table id="myTable">
  <thead>
    <tr>
      <td>offerID</td>
      <td>affid</td>
      <td>deduction</td>
      <td>status</td>
      <td>update entry</td>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>123</td>
      <td>231</td>
      <td>12</td>
      <td>654</td>
      <td>update</td>
    </tr>
    
    <tr>
      <td>123</td>
      <td>231</td>
      <td>12</td>
      <td>654</td>
      <td>update</td>
    </tr>
    
    <tr>
      <td>123</td>
      <td>231</td>
      <td>12</td>
      <td>654</td>
      <td>update</td>
    </tr>
  </tbody>
</table>

Solution 2:

Write an sql query to add data to the table. Then you execute your sql query Example: $SQL= "INSERT INTO table_name (column_name1, column_name2...) VALUES ('$val1', '$val2')"; $exeSQL=mysql_query($SQL) or die (mysql_error());


Post a Comment for "How Do I Add A Row Of Input Boxes, To An Existing Html Form Using Javascript"