The qForms API was designed with a very basic principal in mind—to simplify the process of retrieving and setting form field variables. This was accomplished by creating two of the core API methods: the obj.fieldName.getValue() and obj.fieldName.setValue() methods. Once you've initialized the API, you'll by able to retrieve the value of any form field by using the following syntax:


Regardless whether the field is a text box, radio button, selectbox or some other form field, the getValue() method always retrieves the value of the form field. That means no writing code to loop over arrays to see what elements are selected or checked—the getValue() method works for all field types.

Likewise, the obj.fieldName.setValue() method will set the value of any form field to the value specified. For example:

objForm.SampleText.setValue("Hello World!");

This would set the value of the "SampleText" field to "Hello World!" It's as easy as that. For example, to create a button that displays the contents of a field called "SampleText" to the screen, you just need the following:


When a qForm object is created, the object is a global object—this means you can access the form object from any function within the template. If you have more then one form in the document, you can also initialize more then one qForm object. Just make sure to give each qForm object a unique name.

The qForms API includes methods for handling most of the common problems developers face. The qForms API includes:

  • Common methods for setting and retrieving form field values
  • Automatically prevents forms from being submitted multiple times
  • Dozens of easy to use validation methods
  • An extendable API
  • Automatic Event Capturing
  • Methods for handling complex tasks dealing with form fields—such as transfering items between select boxes
  • The ability to lock/disable form fields (Works with Netscape v3.0!!!)
  • The API was written for Netscape v3.0 and higher
  • And much, much more...

Event Capturing
One of the most unique features of the qForms API is its ability to automatically attach events to your forms fields. The qForms API takes advantage of this capability in several ways.

Whenever a new qForms object is created, several events are automatically attached to the form's onSubmit handler. These events provide several key pieces of functionality that are normally a burden to program.

The most common piece of functionality web developers probably code, is for form validation. The qForms API provides an entire library of useful validation methods for you to use. When a form is submit, all validation rules defined for the form are test and if an errors occur, they are reported to the user and the submission request is cancelled automatically.

Another common problem developers face is preventing duplicate data from being submitted to the server. While there is no way to completely prevent this from happening, we can take steps to help prevent it. Probably the most common reason duplicate data gets created is because an impatient user has repeatedly clicked the submit button. The qForm API automatically prevents this from happening, just by initializing the form! It does this by attaching an event to the form's onSubmit event that ensures only a single submission is allowed. Now how cool is that!

[< Back] [Index] [Next >]