HTML
  Home arrow HTML arrow Page 4 - Using the HTML Table Element as a Recordse...
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
HTML

Using the HTML Table Element as a Recordset
By: Chrysanthus Forcha
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 5
    2008-07-21

    Table of Contents:
  • Using the HTML Table Element as a Recordset
  • Minimum Requirements of a Read/Write Recordset
  • Our Illustrative Web Page
  • Editing Data
  • Add a Row

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Using the HTML Table Element as a Recordset - Editing Data


    (Page 4 of 5 )

    The following code would return or set the text and/or code that is in the table cell in row i and column j.

    document.getElementById('Recordset1').rows[i].cells[j].innerHTML

    Note the innerHTML property of the Table Cell object in the statement. Also note that counting of rows or cells or columns begins from zero.

    Now, add the following button (code) to the body element in the above file content.


    <br /><br />

    <button type="button" onclick="modifyRow(2)">Modify Row</button>


    The above button will call the following function, which uses an array. Include this code in the JavaScript above.


    arr1 = new Array(6)

    arr1[0]="70";

    arr1[1]="Wright";

    arr1[2]="30";

    arr1[3]="Sales";

    arr1[4]="4";

    arr1[5]="18045.50";


    function modifyRow(rowNo)

    {

    for (j=0;j<6;j++)

    {

    document.getElementById('Recordset1').rows[2].cells[j].innerHTML = arr1[j];

    }

    }


    The function takes the row number as argument. It replaces all the cell values of the row with the values of the array. If you want to edit only the content of one table cell, you do not need the “for” loop. You can now open the file in a browser and test the code.

    Delete a Row

    The following statement would delete the row whose index is given, from a table. The index and the position of the deleted row are taken up by the row below it.

    document.getElementById('Recordset1').deleteRow(i)


    Now, add the following button (code) to the body element in the above file content.


    <br /><br />

    <button type="button" onclick="deleteRow(3)">Delete Row</button>


    The above button will call the following function. Include this code in the JavaScript above.


    function deleteRow(rowNo)

    {

    document.getElementById('Recordset1').deleteRow(3)

    }


    The function takes the row number 3 as argument. It deletes the row. The row that had the index, namely 4, is now the row with the index 3. You can try the code.

    More HTML Articles
    More By Chrysanthus Forcha


       · Did you know that HTML indirectly gives you a recordset? This article explains all...
       · Is this supposed to be valid HTML? It's neither XHTML (there aren't any quotes...
       · I intended to give just the important points. All what you have said can be added in...
     

    HTML ARTICLES

    - Comparing Browser Response to Active Client ...
    - Testing Browser Response to Active Client Pa...
    - Active Client Pages: Completing the Code for...
    - ACP and Browsers: Setting up an Example
    - How Browsers Respond to Active Client Pages
    - Completing a Tree with Active Client Pages
    - HTML Form Verification and ACP
    - Building an ACP Tree
    - Completing an ACP 3D HTML Table Image Gallery
    - Building an ACP 3D HTML Table Image Gallery
    - A Multiple Page Image Gallery with Active Cl...
    - Building an Image Gallery with Active Client...
    - Concluding a Menu for All Browsers
    - A Vertical Menu for All Browsers
    - Downloading Long HTML Pages with ACP







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek