Home arrow HTML arrow Page 4 - Building Single Row Database Forms with HTML
HTML

Building Single Row Database Forms with HTML


Welcome to the second chapter of a thirteen part series about creating database forms with HTML. In this article, we will continue our discussion on single-row forms and explain how to send changes to the server database. We will also go over the recordset and the common functions used to manipulate the corresponding form.

Author Info:
By: Chrysanthus Forcha
Rating: 5 stars5 stars5 stars5 stars5 stars / 4
July 16, 2008
TABLE OF CONTENTS:
  1. · Building Single Row Database Forms with HTML
  2. · Sending Changes to Server Database
  3. · The Form Code
  4. · The Nature of the Recordset
  5. · The disableButtons(selectedButtons) Function

print this article
SEARCH DEVARTICLES

TOOLS YOU CAN USE

advertisement
Building Single Row Database Forms with HTML - The Nature of the Recordset
(Page 4 of 5 )

The recordset is a TABLE element with a style property of display:none. This table is at the bottom of the web page just before the end tag (</body>) of the BODY element. The field value of a row is the content of the TD element. It is good to design a web page so that elements are rendered (displayed) as they arrive at the browser. In our case, we need to see the form first before we see the values of the form fields or do anything with the recordset. That is why the recordset table is at the bottom of the web page.

The word “field” in this context can mean two things. It can mean a cell in a row of the recordset or it can mean the rectangle of the HTML INPUT element that receives the text you type.

There are seven fields (TD elements) in each row of the recordset. The first field in the row corresponds to the top-most Input element of the form. The next field corresponds to the second top-most Input element of the form, and so on until the sixth corresponding field. The last field of the row is not displayed on the form. This field is used to indicate whether its particular row in the recordset has been edited. Any row (record) that has not been edited has a value of –1 for this field. When a row of the recordset is edited, its value for this field becomes the row number of its copied row in the Transmitted Table. We shall see the reasons for this later.

Common Functions

All the code (JavaScript) that manipulates the form is in the web page. There are some functions that are used by other functions. These are common functions. I start by explaining these first.

Activating and Deactivating the INPUT Controls

When the form is first displayed, the text input fields are read-only. So you cannot change the content by simply clicking it with the mouse pointer and typing.


The makeReadOnlyInputControls() Function

This function makes all the text Input controls read-only. The code is:


function makeReadOnlyInputControls()

{

for (j=0;j<6;j++) //there are 6 input text controls

{

//form the control ID

ID = "EI" + j;

document.getElementById(ID).readOnly=true;

}

}

There are six text Input elements with IDs: EI0, EI1, EI2, EI3, EI4, EI5, and EI6. The above function gets these IDs for the six Input elements with the following statement:


ID = "EI" + j;


Many other functions use this technique, so I will not explain it again in order to save time. Every other thing in the function is self-explanatory.

The makeWriteInputControls() Function

Before you can type anything into the Input elements, this function has to be called so that the text controls can be made to receive text. The code is:


function makeWriteInputControls()

{

for (j=0;j<6;j++) //there are 6 input text controls

{

//form the control ID

ID = "EI" + j;

document.getElementById(ID).readOnly=false;

}

}



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