Search - Articles
DevASP.NET for ASP.NET, VB.NET, XML and C# (C-Sharp) Developers Tuesday, March 03, 2009
Dev Articles
Search Directory
ASP.NET
VB.Net
C-Sharp
SQL Server
 

Adding new row Using JavaScript.

Author: DevASP
Download Source Code : 581_AddNewRow.zip

This article is about how you can add a new row in you web form using JavaScript. If you want to add a new row in the table of your web form you didn’t need to go back to the server so that.........

 

Steps you will do.

 

 

Start visual studio and create a new web application.

 

Open the HTML design of your web page and add the following JavaScript functions before closing the head tag.

 

 

<SCRIPT LANGUAGE="JavaScript">

  function addRow(id){

    var tbody = document.getElementById

            (id).getElementsByTagName("TBODY")[0];

    var row = document.createElement("TR")

    var td1 = document.createElement("TD")

    td1.appendChild(document.createTextNode("column 1"))

    var td2 = document.createElement("TD")

    td2.appendChild (document.createTextNode("column 2"))

    row.appendChild(td1);

    row.appendChild(td2);

    tbody.appendChild(row);

  }

 

</script>

 

Add the following HTML code to design the layout of your web page.

 

 

<BODY bgcolor=#009999>

<center>

<h3>Dont forget to visit www.devasp.com<br>

<a href="http://www.devasp.com">www.devasp.com</a>

</h3>

 

<a href="javascript:addRow('myTable')">Add row</a>

<table id="myTable" cellspacing="0" border="1">

  <tbody> 

    <tr>

      <td>row1_column1</td><td>row1_column1</td>

    </tr>

  </tbody>

</table>

</center>

 

</body>

 

 

Run you application and click the link to add new row in the table.

 

 

 

Article Comments
Hello,

If I add it to a form for a text box, then how could I get it's value from code behind, I was trying to get it with request.form, but it was not working. If you could give me an example, I will b so greatful to you.
Thanks
Ceema

Posted on 3/2/2007 11:13:07 AM by ceema

Adding new row Using JavaScript.

Posted on 4/6/2007 2:09:41 AM by Senthil Kumar

Thank u about the script. please subscribe any any script in my account. your readers.

Posted on 4/12/2007 5:53:19 AM by soubam koginoor

   
Add Article Comment:
Name :
Email Address :
   
Comments :
 
   
<< Implementing Filter Effect on an Image.

Disclaimer - Privacy
© 2002-2017 DevASP.net