Hi Folks,
Could you please help me to resolve the following problem.
Currently I have 5 text fields and 1 button in row of a table. When I'm clicking on the button it's adding another row which contains the same fields. It's working fine. Now, I've to modify the layout a little but want to keep the functionality same. I want to have the first 2 fields under one <tr> </tr> group and the rest (i.e. 3 text fields and the button in another <tr> </tr> group. When I'll click the button it should add all the 5 text fields and the button in the similar way. Could you please have a look into the following code and help me out ?
The Current Working Code ::
File Name :: Probir.jsp
***************************************************
<html>
<head>
<title>New Entry Form</title>
<script>
function add_row()
{
var n = window.event.srcElement;
var nr1 = n.parentNode.parentNode;
var tb = nr1.parentNode;
var nr2 = tb.insertRow();
var num = nr1.childNodes.length;
for (var i = 0; i < num; i++)
{
var nc = nr2.insertCell();
nc.innerHTML = nr1.childNodes.innerHTML;
}
}
</script>
</head>
<body>
<table width="640">
<tr>
<td> <input type="text" name="TEXT_A" /> </td>
<td> <input type="text" name="TEXT_B" /> </td>
<td> <input type="text" name="TEXT_C" /> </td>
<td> <input type="text" name="TEXT_D" /> </td>
<td> <input type="text" name="TEXT_E" /> </td>
<td><input type="button" name="add" value="Add" onclick="add_row()"/></td>
</tr>
</table>
</body>
</html>
***************************************************
I want to change the layout as following ::
***************************************************
<body>
<table width="640">
<tr>
<td> <input type="text" name="TEXT_A" /> </td>
<td> <input type="text" name="TEXT_B" /> </td>
</tr>
<tr>
<td> <input type="text" name="TEXT_C" /> </td>
<td> <input type="text" name="TEXT_D" /> </td>
<td> <input type="text" name="TEXT_E" /> </td>
<td><input type="button" name="add" value="Add" onclick="add_row()"/></td>
</tr>
</table>
</body>
***************************************************
Could anybody help me to modify the function add_row() to achieve this.
Thanks a lot.
Could you please help me to resolve the following problem.
Currently I have 5 text fields and 1 button in row of a table. When I'm clicking on the button it's adding another row which contains the same fields. It's working fine. Now, I've to modify the layout a little but want to keep the functionality same. I want to have the first 2 fields under one <tr> </tr> group and the rest (i.e. 3 text fields and the button in another <tr> </tr> group. When I'll click the button it should add all the 5 text fields and the button in the similar way. Could you please have a look into the following code and help me out ?
The Current Working Code ::
File Name :: Probir.jsp
***************************************************
<html>
<head>
<title>New Entry Form</title>
<script>
function add_row()
{
var n = window.event.srcElement;
var nr1 = n.parentNode.parentNode;
var tb = nr1.parentNode;
var nr2 = tb.insertRow();
var num = nr1.childNodes.length;
for (var i = 0; i < num; i++)
{
var nc = nr2.insertCell();
nc.innerHTML = nr1.childNodes.innerHTML;
}
}
</script>
</head>
<body>
<table width="640">
<tr>
<td> <input type="text" name="TEXT_A" /> </td>
<td> <input type="text" name="TEXT_B" /> </td>
<td> <input type="text" name="TEXT_C" /> </td>
<td> <input type="text" name="TEXT_D" /> </td>
<td> <input type="text" name="TEXT_E" /> </td>
<td><input type="button" name="add" value="Add" onclick="add_row()"/></td>
</tr>
</table>
</body>
</html>
***************************************************
I want to change the layout as following ::
***************************************************
<body>
<table width="640">
<tr>
<td> <input type="text" name="TEXT_A" /> </td>
<td> <input type="text" name="TEXT_B" /> </td>
</tr>
<tr>
<td> <input type="text" name="TEXT_C" /> </td>
<td> <input type="text" name="TEXT_D" /> </td>
<td> <input type="text" name="TEXT_E" /> </td>
<td><input type="button" name="add" value="Add" onclick="add_row()"/></td>
</tr>
</table>
</body>
***************************************************
Could anybody help me to modify the function add_row() to achieve this.
Thanks a lot.