JS Operation table

Source: Internet
Author: User

<!DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "Http://www.w3.org/TR/html4/loose.dtd "><HTML> <Head>  <title>New Document</title>  <styletype= "Text/css">Table{Border-collapse:collapse;Border:None;width:200px;        }TD{Border:Solid #000 1px;        }    </style>    <Script>      //gets the current domain at index, (is the number of XXX)      functionGetelementorder (Field,tableid) {varInputs=Document.getelementsbyname (field.name); varLen=inputs.length; varIndex= 0;  for  (varI= 0; I<Len; I++){              if(Inputs==field) {Index=i;  Break; }                }        returnindex; }     functionInsertRow (tableid,table_data) {//Get Tbody (create a table will have a default tbody load tr TD here to get tale a tbody)     varOtbody=document.getElementById (tableid). tbodies[0];//This is equivalent to the item (0) in JS using the array ordinal directly called the Visible JavaScript authoritative guide P368     varOtbodydata=document.getElementById (table_data). tbodies[0]; varLen=oTBODYData.rows.length; //Traverse data Row      for ( varI= 0; I<=Len; I++) {otbody.appendchild (Otbodydata.rows[i].clonenode (true)); }         }    functionDeleteRow (field,targettable) {varFindex=Getelementorder (Field)-1;//minus 1 Here is because a row in SourceTable is hidden.document.getElementById (targettable). DeleteRow (Findex); }    </Script> </Head> <Body>      <TableID= "Table_data"class= "Data"style= "Display:none">          <TR>            <TD><inputtype= "text"name="">1</TD>            <TD><inputtype= "text"name= "2"></TD>             <TD><inputtype= "text"></TD>              <TD><inputtype= "button"value= "Delete"onclick= "DeleteRow (this, ' table_list ');"></TD>          </TR>                </Table>           <TableID= "Table_list"class= "List">      <TR>        <TD>Age<TD>        <TD>Gender</TD>        <TD><inputtype= "button"name= "Del"onclick= "DeleteRow (this)"></TD>        <TD><inputtype= "button"value= "Add"name= "Insert"onclick= "InsertRow (' table_list ', ' Table_data ')"></TD>      </TR>      </Table> </Body></HTML>

method is very common, do not knock once who rush to say that they will.

JS Operation table

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.