HTML
  Home arrow HTML arrow Page 2 - Using the Find Functions for HTML Database...
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 Find Functions for HTML Database Forms
By: Chrysanthus Forcha
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 2
    2008-08-20

    Table of Contents:
  • Using the Find Functions for HTML Database Forms
  • The ordinarySearch() function
  • The getTwoWords() Function
  • The find() Function

  • 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 Find Functions for HTML Database Forms - The ordinarySearch() function


    (Page 2 of 4 )

    When the recordset is not sorted, this function does the searching. It takes as arguments the cell value whose row is searched, and the index of the column having the cell. This cell value is called the key. If it sees the value, it returns the row index. If it doesn't see the value, it returns the total number of rows in the recordset; note that this is one unit higher than the maximum row index. It is up to the calling function to interpret the result. This is the function:


    function ordinarySearch(key, titleInx)

    {

    for (i=0; i<numberOfRows; ++i)

    {

    if (document.getElementById('Recordset').rows[i].cells[titleInx].innerHTML == key)

    return i;

    }


    return numberOfRows;

    }


    The binarySearch() function

    This function is called when the recordset is sorted. When the recordset is sorted, the search from this function is very fast, much faster than that of the ordinary search. The function takes as arguments the same parameters that the ordinary search takes. It returns the same values under the same conditions. If the user wants to be sure to have a fast search, he can sort the recordset based on the column, which has the cell value he will find. After that he finds the cell value (row) by clicking the Find button. This is the binarySearch() function:


    function binarySearch(key, titleInx)

    {

    var left = 0;

    var right = numberOfRows - 1;

     

    while (left <= right)

    {

    var mid = parseInt((left + right)/2);

    if (document.getElementById('Recordset').rows[mid].cells[titleInx].innerHTML == key)

    return mid;

    else if (document.getElementById('Recordset').rows[mid].cells[titleInx].innerHTML < key)

    left = mid + 1;

    else

    right = mid - 1;

    }

     

    //when element is not found

    return numberOfRows;

    }


    If you want to know how the function operates, consult the article I wrote. The recordset is like a two dimensional array. The binarySearch() function here is slightly different from the one I wrote in the article. In that article, searching is done only for a one-dimensional array. Here the function is different, because the two dimensional array aspects have to be taken into consideration.

    More HTML Articles
    More By Chrysanthus Forcha


       · Let's continue with this part of the series.Chrys
     

    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 1 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek