Home arrow HTML arrow Page 5 - Tabular Database Form Functions with HTML
HTML

Tabular Database Form Functions with HTML


Welcome to the ninth part of a thirteen-part series on HTML database forms. In the previous part we began our discussion of Tabular forms, having dealt with Single-Row forms up until that point. In this part we continue our discussion of what functions to use with Tabular forms and how they are different from their Single-Row counterparts.

Author Info:
By: Chrysanthus Forcha
Rating: 4 stars4 stars4 stars4 stars4 stars / 3
September 10, 2008
TABLE OF CONTENTS:
  1. · Tabular Database Form Functions with HTML
  2. · The editRow() Function
  3. · The includeInTransmittedTable()
  4. · The deleteRow() Function
  5. · The swap() and quickSort() Function

print this article
SEARCH DEVARTICLES

TOOLS YOU CAN USE

advertisement
Tabular Database Form Functions with HTML - The swap() and quickSort() Function
(Page 5 of 5 )

Here these functions have to take into consideration the fact that the recordset has Input Text Controls for each visible cell. These are the new functions:


function swap(m,n)

{

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

{

if (z <= 5)

{

//form the Input Text Control ID for the parameter, m

IDM = "EI" + m + z;

 

//form the Input Text Control ID for the parameter, n

IDN = "EI" + n + z;


temp = document.getElementById(IDM).value;

document.getElementById(IDM).value = document.getElementById(IDN).value;

document.getElementById(IDN).value = temp;

}

else

{

temp = document.getElementById('Recordset').rows[m].cells[z].innerHTML;

document.getElementById('Recordset').rows[m].cells[z].innerHTML = document.getElementById('Recordset').rows[n].cells[z].innerHTML;

document.getElementById('Recordset').rows[n].cells[z].innerHTML = temp;

}

}

}



function quickSort(left,right,titleInx)

{//the function receives a recordset, indices for the left and right rows, and the index for the title column.

i = left;

j = right;

 


//form the Input Text Control ID for the parameter, left

IDLeft = "EI" + left + titleInx;

 

 

//form the Input Text Control ID for i

IDI = "EI" + i + titleInx;


//form the Input Text Control ID for j

IDJ = "EI" + j + titleInx;


if(document.getElementById(IDI).value > document.getElementById(IDJ).value)

{

swap(i, j);

}


do //increment i and decrement j, then swap if necessary

{

do

{

if ((i+1)<=right) //do not increment i beyond the index for the right element

{

++i; IDI = "EI" + i + titleInx;

}

} while (document.getElementById(IDI).value < document.getElementById(IDLeft).value)

do

{

if ((j-1)>=left) //do not decrement j beyond the index for the left element

{

--j; IDJ = "EI" + j + titleInx;

}

} while (document.getElementById(IDJ).value > document.getElementById(IDLeft).value)

 

if (i<j)

{

swap(i, j);

}

} while (i < j)


swap(j, left);

var k = j; //the pivot.

 

var leftLeft = left; //the index for the left element of the left sub-list, initialized

 

if ((k-1)>=left) //we do not want a value for k that will be less than the left index

{

var leftRight = k - 1; //the index for the right element of the left sub-list, initialized

}

if ((k+1)<=right) //we do not want a value for k that will be greater than the right index

{

var rightLeft = k + 1; //the index for the left element of the right sub-list, initialized

}

var rightRight = right; //the index for the right element of the right sub-list, initialized



//recursion for the left sub-list - only called if a left sub-list exists

if (k != left)

{

quickSort(leftLeft,leftRight,titleInx);

}

 

//recursion for the right sub-list - only called if a right sub-list exists

if (k != right)

{

quickSort(rightLeft,rightRight,titleInx);

}

}


The finalize()

The main aim of this function is to submit the data in the Transmitted table. The function has been modified for some of the reasons given above. This is the new function:


function finalize(ID)

{

if (ID == "Do1")

{

document.getElementById('Don1').click();

self.close(); //close the window after submit if the Done button was clicked

}

else

{

document.getElementById('Sa1').click();

}

}



In this part of the series we have not considered larger text (textarea), images and video clips. I will consider video clips in a separate article. In the next parts I will consider larger texts, images and then I will also consider the program that receives the transmitted data at the server and the program sends the web page from the server.

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