JS Delete node

Source: Internet
Author: User

<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 ">
<title> Add table Row </title>
<script language= "javascript" >//example:obj = Findobj ("Image1");
function Findobj (theobj, thedoc) {
var p, I, foundobj;
if (!thedoc) thedoc = document;
if (p = theobj.indexof ("?")) > 0 && parent.frames.length) {
Thedoc = parent.frames[theobj.substring (p+1)].document;
Theobj = theobj.substring (0,p);
}
if (! ( Foundobj = Thedoc[theobj]) && thedoc.all) foundobj = Thedoc.all[theobj];
for (i=0;!foundobj && i < theDoc.forms.length; i++) foundobj = Thedoc.forms[i][theobj];
for (i=0;!foundobj && thedoc.layers && i < theDoc.layers.length; i++) foundobj = Findobj (theobj,thedoc . layers[i].document);
if (!foundobj && document.getElementById) foundobj = document.getElementById (theobj); return foundobj;
}
Add a participant to fill in the line
function Addsignrow () {//reads the line number of the last line and holds it in the Txttrlastindex text box
var txttrlastindex = findobj ("Txttrlastindex", document);
var RowID = parseint (Txttrlastindex.value);

var signframe = findobj ("Signframe", document);
Adding rows
var newtr = Signframe.insertrow (signFrame.rows.length);
Newtr.id = "Signitem" + RowID;

Add Column: Ordinal
var Newnametd=newtr.insertcell (0);
Add Column Contents
newnametd.innerhtml = NewTR.rowIndex.toString ();

Add Column: Name
var Newnametd=newtr.insertcell (1);
Add Column Contents
newnametd.innerhtml = "<input name= ' txtname" + RowID + "' id= ' txtname" + RowID + "' type= ' text ' size= '/> '";

Add Column: E-mail
var Newemailtd=newtr.insertcell (2);
Add Column Contents
newemailtd.innerhtml = "<input name= ' Txtemail" + RowID + "' id= ' txtemail" + RowID + "' type= ' text ' size= '"/> ";

Add Column: Delete button
var Newdeletetd=newtr.insertcell (3);
Add Column Contents
newdeletetd.innerhtml = "<div align= ' center ' style= ' width:40px ' ><a href= ' javascript:; ' onclick=\ ' Deletesignrow (' Signitem ' + RowID + "') \" > Delete </a></div> ";

Advance line number to next line
Txttrlastindex.value = (RowID + 1). ToString ();
}
Delete the specified line
function Deletesignrow (ROWID) {
var signframe = findobj ("Signframe", document);
var Signitem = findobj (rowid,document);

Gets the index of the row that will be deleted
var rowIndex = Signitem.rowindex;

Delete the row for the specified index
Signframe.deleterow (RowIndex);

Rearrange the ordinal, if there is no ordinal, this step is omitted
for (i=rowindex;i<signframe.rows.length;i++) {
signframe.rows[i].cells[0].innerhtml = i.ToString ();
}
}//emptying the list
function Clearallsign () {
if (Confirm (' OK to clear all participants? ‘)){
var signframe = findobj ("Signframe", document);
var rowscount = signFrame.rows.length;

Loop delete rows, remove them from the last line
for (i=rowscount-1;i > 0; i--) {
Signframe.deleterow (i);
}

Reset the last line number to 1
var txttrlastindex = findobj ("Txttrlastindex", document);
Txttrlastindex.value = "1";

Pre-Add a row
Addsignrow ();
}
}
</script>
<body>
<div>
<table width= "613" border= "0" cellpadding= "2" cellspacing= "1" id= "Signframe" >
<tr id= "Trheader" >
&LT;TD width= "bgcolor=" #96E0E2 "> Serial number </td>
&LT;TD width= "Up" bgcolor= "#96E0E2" > User name </td>
&LT;TD width= "98" bgcolor= "#96E0E2" > E-mail </td>
&LT;TD width= "align=" "Center" bgcolor= "#96E0E2" >&nbsp;</td>
</tr>
</table>
</div>
<div>
<input type= "button" Name= "Submit" value= "Add participant" onclick= "Addsignrow ()"/>
<input type= "button" Name= "Submit2" value= "Empty" onclick= "clearallsign ()"/>
<input name= ' txttrlastindex ' type= ' hidden ' id= ' txttrlastindex ' value= ' 1 '/>
</div>
</body>

JS Delete node

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.