Add Data to table in runtime?

0 votes
62 views
asked Jun 21, 2013 in HTML by john (4,220 points)
edited Jun 21, 2013 by admin
hi

   in my case i read all the data from my server i want populate those data in table runtime?

1 Answer

0 votes
answered Jun 21, 2013 by admin (8,115 points)

Try this:

HTML

<table id="datatable">
       <tr>
        <td><input type="text"  /></td>
       </tr>
       <tr>
        <td><input type="text"  /></td>
       </tr>
     </table>

<button type="button" id="add" onclick="addRow('dataTable')">
        <b>Add</b>
 </button>
JS

 $(document).ready(function() {
    $('#add').click(function(){
        $('#datatable').append(' <tr> <td>Account No</td> <td>:</td> <td colspan="2"><input size="20" type="text" /></td> <td>Bill No</td> <td>:</td> <td><input type="text" /></td> </tr> <tr> <td>Name</td> <td>:</td> <td colspan="2"><input type="text" /></td> <td>Bill date</td> <td>:</td> <td><input type="text" /></td> </tr>');
});
});
Fiddle: http://jsfiddle.net/zLXmQ/4/

...