Home arrow HTML arrow Page 3 - Using the Find Functions for HTML Database Forms
HTML

Using the Find Functions for HTML Database Forms


You may have any number of reasons to find a particular recordset in a database. Sometimes finding what you want is easier said than done. This article walks you through the different search functions (also known as Find functions) and shows you when you should use them. This is the seventh part of a thirteen part series that focuses on database forms with HTML.

Author Info:
By: Chrysanthus Forcha
Rating: 5 stars5 stars5 stars5 stars5 stars / 2
August 20, 2008
TABLE OF CONTENTS:
  1. · Using the Find Functions for HTML Database Forms
  2. · The ordinarySearch() function
  3. · The getTwoWords() Function
  4. · The find() Function

print this article
SEARCH DEVARTICLES

TOOLS YOU CAN USE

advertisement
Using the Find Functions for HTML Database Forms - The getTwoWords() Function
(Page 3 of 4 )

The find() function issues a prompt dialog box. This dialog box has only one input text control. In this control the user types in the title of the column separated by a space and then the value of the cell for the row that the search has to get. The search process needs these two values in order to get the row.

Note: if two or more consecutive rows have this same cell value, any of the rows will be displayed. To limit this, you will have to write your code so that the prompt box receives more than one column title. For simplicity I do not take that into account for this series. Here the prompt dialog box receives only one title name and the cell value.

The prompt dialog box returns the two words as a single string. The getTwoWords() function separates the string into the two separate words. As an argument it receives the string that has the two words. It returns the two words in an array. If the user typed in correctly, the first element in the array is the title and the second is the cell value. This is the function:


function getTwoWords(entry)

{

var firstWord = "";

var secondWord = "";

var i = 0;


do

{

firstWord+= entry.charAt(i);

++i;

if (i == entry.length)

break;

} while (entry.charAt(i) != " ")


if (i != entry.length)

{

++i; //take account of the space

do

{

secondWord+= entry.charAt(i);

++i;

} while (i <= (entry.length-1))

}


var tempArr = new Array(2);

tempArr[0] = firstWord;

tempArr[1] = secondWord;

return tempArr;

}


In this function there are two while loops. The first while loop extracts the first word. The second while loop extracts the second word if it was typed (that is, if while extracting the first word, the iteration of the received string was not complete). You can use Regular Expressions to achieve this. I have not used one here because many programmers still have not mastered Regular Expressions. However, I will soon be using them in my articles.


blog comments powered by Disqus
HTML ARTICLES

- HTML5 Boilerplate: Working with jQuery and M...
- HTML5 Boilerplate Introduction
- New API Platform for HTML5
- BBC Adopts HTML 5, Mozilla Addresses Issues
- Advanced Sticky Footers in HTML and CSS
- HTML and CSS Sticky Footers
- Strategy Analytics Predicts HTML5 Phones to ...
- HTML5 Guidelines for Web Developers
- Learning HTML5 Game Programming
- More Engaging CSS3 and HTML Background Effec...
- Engaging HTML and CSS3 Background Effects
- More Web Columns with CSS3 and HTML
- Columns with CSS3 and HTML
- Creating Inline-Block HTML Elements with CSS
- Drag and Drop in HTML5: Parsing Local Files

Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 



© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 8 - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials