Home arrow HTML arrow Page 4 - Sorting for Database Forms with HTML
HTML

Sorting for Database Forms with HTML


Welcome to the sixth part of a fourteen part series detailing how to create database forms in HTML. In this article, we will discuss sorting and its various functions as well as the boolean values that come as a result. Please join us as we tackle these issues.

Author Info:
By: Chrysanthus Forcha
Rating: 5 stars5 stars5 stars5 stars5 stars / 2
August 13, 2008
TABLE OF CONTENTS:
  1. · Sorting for Database Forms with HTML
  2. · The sort() Function continued
  3. · The getColumnIndex() Function
  4. · The titleBoolArr Array

print this article
SEARCH DEVARTICLES

TOOLS YOU CAN USE

advertisement
Sorting for Database Forms with HTML - The titleBoolArr Array
(Page 4 of 4 )

This is a JavaScript two-dimensional array having two columns. The first column holds the titles (ID, Name, etc); the second holds the corresponding indices. The second column holds either a “true” or a “false” value, which indicates whether the corresponding column is sorted. The titles have been written in such a way that the recordset column indices are the corresponding row indices of the titleBoolArr array. This is the construction of the array and initialization:


var titleBoolArr = new Array(6)

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

{

titleBoolArr[i] = new Array(2);

}


//initialize the array

titleBoolArr[0][0] = "ID"; titleBoolArr[0][1] = "false";

titleBoolArr[1][0] = "Name"; titleBoolArr[1][1] = "false";

titleBoolArr[2][0] = "Department"; titleBoolArr[2][1] = "false";

titleBoolArr[3][0] = "Job"; titleBoolArr[3][1] = "false";

titleBoolArr[4][0] = "Years"; titleBoolArr[4][1] = "false";

titleBoolArr[5][0] = "Salary"; titleBoolArr[5][1] = "false";


First a one-dimensional array is created with the line:


var titleBoolArr = new Array(6)


Next, each element of the array is made an array by the “for” loop. The two dimensional array is actually an array of arrays. JavaScript does not have a single statement for creating a two dimensional array.

The setTitleBool() Function

After sorting, this function indicates that a particular column has been sorted by setting the Boolean value for the column to “true” in the titleBoolArr array. It also indicates that no other column is sorted by setting all the other Boolean values to “false”. This is the function:


function setTitleBool(theTitle)

{

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

{

if (titleBoolArr[i][0] == theTitle)

titleBoolArr[i][1] = "true";

else

titleBoolArr[i][1] = "false";

}

}


We shall continue in the next part of the series.


DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

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 2 - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials