mili
05-01-2003, 09:00 AM
I've been sitting on this problem for days and not able to find a solution for this. please can someone help me in this?
I have a table and I'm adding rows dynamically by hitting a "Add Row" button.My questions are:
1. How can I delete multiple rows at one shot by checking a check box (after adding the rows dynamically)
2. How can I store the values entered in these fields and post the form?
PS: I suck at JS and I'm still in the process of learning.
Thanks,
Here is my code:
<html>
<html>
<head>
<script language="JavaScript" type="text/javascript">
function addRow(id){
var tbody = document.getElementById
(id).getElementsByTagName("TBODY")[0];
var row = document.createElement("TR")
var td1 = document.createElement("TD")
td1.innerHTML = "<input type=text align=center size=25 name='"+name+"' id='"+name+"'>";
//td1.appendChild(document.createTextNode("column 1"))
var td2 = document.createElement("TD")
td2.innerHTML = "<input type=text align=center size=25 name='"+name+"' id='"+name+"'>";
//td2.appendChild (document.createTextNode("column 2"))
var td3 = document.createElement("TD")
td3.innerHTML = "<input type=text align=center size=25 name='"+name+"' id='"+name+"'>";
//td3.appendChild (document.createTextNode("column 2"))
row.appendChild(td1);
row.appendChild(td2);
row.appendChild(td3);
tbody.appendChild(row);
}
</script>
</head>
<body>
<table id="myTable" cellspacing="0" width="100%" border="1">
<tbody>
<tr bgcolor="#cfcfcf">
<td width="30%">column1</td><td width="30%">column2</td><td width="30%">column3<a href="javascript:addRow('myTable')">Add row</a></td>
</tr>
</tbody>
</table>
</body>
</html>
I have a table and I'm adding rows dynamically by hitting a "Add Row" button.My questions are:
1. How can I delete multiple rows at one shot by checking a check box (after adding the rows dynamically)
2. How can I store the values entered in these fields and post the form?
PS: I suck at JS and I'm still in the process of learning.
Thanks,
Here is my code:
<html>
<html>
<head>
<script language="JavaScript" type="text/javascript">
function addRow(id){
var tbody = document.getElementById
(id).getElementsByTagName("TBODY")[0];
var row = document.createElement("TR")
var td1 = document.createElement("TD")
td1.innerHTML = "<input type=text align=center size=25 name='"+name+"' id='"+name+"'>";
//td1.appendChild(document.createTextNode("column 1"))
var td2 = document.createElement("TD")
td2.innerHTML = "<input type=text align=center size=25 name='"+name+"' id='"+name+"'>";
//td2.appendChild (document.createTextNode("column 2"))
var td3 = document.createElement("TD")
td3.innerHTML = "<input type=text align=center size=25 name='"+name+"' id='"+name+"'>";
//td3.appendChild (document.createTextNode("column 2"))
row.appendChild(td1);
row.appendChild(td2);
row.appendChild(td3);
tbody.appendChild(row);
}
</script>
</head>
<body>
<table id="myTable" cellspacing="0" width="100%" border="1">
<tbody>
<tr bgcolor="#cfcfcf">
<td width="30%">column1</td><td width="30%">column2</td><td width="30%">column3<a href="javascript:addRow('myTable')">Add row</a></td>
</tr>
</tbody>
</table>
</body>
</html>