I have written a script that adds a row to a table and moves the
values from the initial line into the new line
What I am now trying to do is add a button in each new row that will
allow me to delete the row created
I am having no luck doing this
if i add a button using createelement and assosiate code with it the
code executes when i create the row
any help would be much appreciated
script as follows:
<HTML><HEAD>
<TITLE>test</TITLE>
<script LANGUAGE="JavaS cript">
__uid = 0;
doc = document;
function addRowTo(id) {
var tbl = doc.getElementB yId(id);
//create a new row
var newrow = doc.createEleme nt("TR");
var newcol , newinput;
newcol = doc.createEleme nt("TD");
newcol.width = 200;
newinput = doc.createEleme nt("input");
newinput.name = "date";
newinput.size = 20;
newinput.value = doc.main.date.v alue
newcol.appendCh ild(newinput);
newrow.appendCh ild(newcol);
newcol = doc.createEleme nt("TD");
newcol.width = 200;
newinput = doc.createEleme nt("input");
newinput.name = "start"+__u id;
newinput.size = 20;
newinput.value = doc.main.start. value
newcol.appendCh ild(newinput);
newrow.appendCh ild(newcol);
newcol = doc.createEleme nt("TD");
newcol.width = 200;
newinput = doc.createEleme nt("input");
newinput.name = "end"+__uid ;
newinput.size = 20;
newinput.value = doc.main.end.va lue
newcol.appendCh ild(newinput);
newrow.appendCh ild(newcol);
tbl.appendChild (newrow);
__uid++;
document.main.d ate.value = '';
document.main.s tart.value = '';
document.main.e nd.value = '';
document.main.d ate.focus();
}
</script>
</HEAD>
<body>
<form name="main" method='post'>
<table id="tbl1">
<tbody id="tbl1body">
<td>DATE<td>STA RT<td>END
<tr>
<td><input type='text' name='date' size=10 maxlength=200 value=""/>
<td><input type='text' name='start' size=10 maxlength=200 value=""/>
<td><input type='text' name='end' size=10 maxlength=200 value=""/>
<td>
<a href="#" onClick="addRow To('tbl1body')" >
<img border=0 src="/images/add.gif"></a>
</table>
</form></html>
values from the initial line into the new line
What I am now trying to do is add a button in each new row that will
allow me to delete the row created
I am having no luck doing this
if i add a button using createelement and assosiate code with it the
code executes when i create the row
any help would be much appreciated
script as follows:
<HTML><HEAD>
<TITLE>test</TITLE>
<script LANGUAGE="JavaS cript">
__uid = 0;
doc = document;
function addRowTo(id) {
var tbl = doc.getElementB yId(id);
//create a new row
var newrow = doc.createEleme nt("TR");
var newcol , newinput;
newcol = doc.createEleme nt("TD");
newcol.width = 200;
newinput = doc.createEleme nt("input");
newinput.name = "date";
newinput.size = 20;
newinput.value = doc.main.date.v alue
newcol.appendCh ild(newinput);
newrow.appendCh ild(newcol);
newcol = doc.createEleme nt("TD");
newcol.width = 200;
newinput = doc.createEleme nt("input");
newinput.name = "start"+__u id;
newinput.size = 20;
newinput.value = doc.main.start. value
newcol.appendCh ild(newinput);
newrow.appendCh ild(newcol);
newcol = doc.createEleme nt("TD");
newcol.width = 200;
newinput = doc.createEleme nt("input");
newinput.name = "end"+__uid ;
newinput.size = 20;
newinput.value = doc.main.end.va lue
newcol.appendCh ild(newinput);
newrow.appendCh ild(newcol);
tbl.appendChild (newrow);
__uid++;
document.main.d ate.value = '';
document.main.s tart.value = '';
document.main.e nd.value = '';
document.main.d ate.focus();
}
</script>
</HEAD>
<body>
<form name="main" method='post'>
<table id="tbl1">
<tbody id="tbl1body">
<td>DATE<td>STA RT<td>END
<tr>
<td><input type='text' name='date' size=10 maxlength=200 value=""/>
<td><input type='text' name='start' size=10 maxlength=200 value=""/>
<td><input type='text' name='end' size=10 maxlength=200 value=""/>
<td>
<a href="#" onClick="addRow To('tbl1body')" >
<img border=0 src="/images/add.gif"></a>
</table>
</form></html>
Comment