JavaScript Add delete line information

Source: Internet
Author: User

<%@ Page language="C #"autoeventwireup="true"Codebehind="StuInfo.aspx.cs"inherits="Stumanager.stuinfo"%><! DOCTYPE html>"http://www.w3.org/1999/xhtml">"Server"><meta http-equiv="Content-type"Content="text/html; Charset=utf-8"/> <title>add Student info</title> <style type="Text/css">#div1 {width:300px;            height:300px;        border:1px; }    </style> <script type="Text/javascript">//Perform the deletefunction Ben_delete (delrow) {//get the line of the click TR            varTR =DelRow.parentNode.parentNode; //Delete a child row in a tbodydocument.getElementById ('tbody1'). removechild (TR); } window.onload=function () {document.getElementById ("Btn_save"). onclick =function () {//get new Line contents                varName = document.getElementById ("name"). Value; varAge = document.getElementById (" Age"). Value; varTbaleobj = document.getElementById ("tbody1"); //Add a new row at the top                varAddRow = Tbaleobj.insertrow (-1); //Insert data for a new rowAddrow.insertcell (-1). InnerHTML =name; Addrow.insertcell (-1). InnerHTML =name; //Add a button to a new lineAddrow.insertcell (-1). InnerHTML ='<input type= "button" id= "Btn_del" value= "delete" onclick= "ben_delete (this);" />';        };    }; </script>"Form1"runat="Server"> <fieldset style="width:250px;"> <divclass="#div1">Name:<input type="TextBox"Id="name"Name="user_name"Value=" "/><br/>Age :<input type="TextBox"Id=" Age"Name="User_age"Value=" "/><br/> <input type="Button"Id="Btn_save"Name="Btn_save"Value="Save"style="margin-left:180px;margin-top:-10px;""/></div> </fieldset> <div> <table border="1px"style="width:220px;"> <thead> <tr><td colspan="3">student Info table</td></tr> <tr><td>name</td><td>age</td&gt ;<td>delete</td></tr> </thead> <tbody id="tbody1"> </tbody> </table> </div> </form></body>View Code

JavaScript Add delete line information

Related Article

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.