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

Recommended Answers

All 4 Replies

Are you referring to rows in a database, or HTML rows?

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.

Member Avatar for rajarajan2017

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>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.