I have a table like this
<table id="user-data">
<tr>
<th>Name</th>
<th>Email</th>
<th>Contact Number</th>
</tr>
</table>
Now all the fields for the fields like Name, Email and Contact Number is populating from database. Before this I was getting only a single row of content. So I made my script like this
<script type="text/javascript">
var html = $('<tr><td><input type=\"text\" name=\"name\"></td><td><input type=\"text\" name=\"email\"></td><td><input type=\"text\" name=\"contact-number\"></td></tr>');
$('table#user-data').append(html);
</script>
This was adding the single row in the table without any problem. But now I want to add more then single row at a time and the row number will change every time. So can someone tell me how to add given number of rows to the table dynamically? Any help and suggestions will be really appreceable. Thanks
Update I am getting the number of rows in my jQuery. Lets say it is in a variable called Length.
var htmlseems to be constructed independent of any data (the data you mention is being populated from the database). Anyhow, how about your wrap the code which populates a row and iterate over the collection your receive from the database? Clutching at straws here, a jsfiddle would help.