|
-
Mar 12th, 2002, 10:54 AM
#1
onclick add column and image
Hi there,
How do I insert columns when I click on the button. Below written code inserts rows when I click on the button.
<html>
<head>
<title> Add A Row </title>
<script language="JavaScript">
function addRow(id){
var tbody = document.getElementById
(id).getElementsByTagName("TBODY")[0];
var row = document.createElement("TR")
var td1 = document.createElement("TD")
td1.appendChild(document.createTextNode("column 1"))
var td2 = document.createElement("TD")
td2.appendChild (document.createTextNode("column 2"))
row.appendChild(td1);
row.appendChild(td2);
tbody.appendChild(row);
}
</script>
</head>
<body>
<a href="javascript:addRow('myTable')">Add row</a>
<input type="button" value="Add Row" onclick="javascript:addRow('myTable');"><br><br>
<table id="myTable" cellspacing="0" border="1">
<tbody>
<tr>
<td>row1_column1</td>
<td>row1_column2</td>
</tr>
</tbody>
</table>
</body>
</html>
thanx
dp
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|