0

hey,
please can anyone help me to add new row or a column to the table whenever a user clicks on the add button?
thanx in advance

5
Contributors
4
Replies
5
Views
7 Years
Discussion Span
Last Post by vibhaJ
0

hey,
please can anyone help me to add new row or a column to the table whenever a user clicks on the add button?
thanx in advance

This kind of thing is better done with Javascript, if that is a option. Otherwise the user will have to do a submit to the server in order to re-write the list.

0

Adding dynamic rows using JavaScript:

<html>
<head>
<script type="text/javascript">
function insRow()
{
var temp=1;
for (i=1;i<=11;i++)
{
	var x=document.getElementById('myTable').insertRow(0);
	var y=x.insertCell(0);
	var z=x.insertCell(1);
	y.innerHTML=i-1;
	if (i==1) {
		z.innerHTML=eval(temp);
	}else{
		temp+=temp;
		z.innerHTML=eval(temp);
	}
}
}
</script>
</head>

<body>
<table id="myTable" border="1">
<tr align="center">
<td colspan="2">End of the Table</td>
<td></td>
</tr>
</table>
<br />
<input type="button" onclick="insRow()" value="Insert row">
</body>
</html>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.