954,561 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Dynamically add 5 rows in a table




NAME:  
E-MAIL:  

NAME:  
E-MAIL:  

NAME:  
E-MAIL:  

NAME:  
E-MAIL:  

NAME:  
E-MAIL:  


vamsikrishna981
Newbie Poster
1 post since Nov 2011
Reputation Points: 10
Solved Threads: 0
 

Here is a simple example of how to do it (I'm using jquery to make it easier):

<html>

<head>

<script src="jquery-1.6.4.min.js"></script>


<script>

$(function(){
	$('button').click(function(){
		var rowsToAdd = $('input[type=text]').val();

		if(rowsToAdd > 0){

			for(var i = 0; i < rowsToAdd; i++){
				$('table').append('<tr><td>Row Added</td></tr>');
			}
		}
	});
});

</script>

</head>

<body>

<table>
	<tr>
		<td>
		A row in the table
		</td>
	</tr>
</table>

<!-- The textbox allows you to enter a number which will be how many rows to add. -->
<input type="text" /><button>Add Rows</button>

</body>

</html>
stbuchok
Master Poster
730 posts since May 2011
Reputation Points: 120
Solved Threads: 93
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: