![]() |
||
![]() |
Using The qForms API Using the qForm API is very easy. As you've already seen, setting your forms for the API is quite simple. There are only a few key points you need to remember:
Remembering these simple points will avoid the most common problems developers experience when first trying to use the qForms API. The Basics
In the above example, we've creating a new global JavaScript object called "objForm." This
object can be accessed from anywhere within our document. Passing the string "frmExample"
indicates we have a If the form was inside another layer, we'd have to specify the layer in which the form resided inthis is because Netscape v4.x considers layers as part of a new document. For example, if we had a form called "frmExample" inside a layer with the ID of "idForm", we'd initialize the form using the following syntax:
After initializing the form, you'll be able to retrieve and set your form field variables using the getValue() and setValue() methods. For example, to display the value of a multi-select box named "MenuItem", you'd do the following:
This would display the value of all the items selected within the MenuItem select box. If you needed to programmatically change the value of the select boxes, you can use the setValue() method. For example, if two of the values in the select box were "Home" and "Products", we could set the value of the MenuItems by simply calling:
This would make sure that both the "Home" and "Products" listings were selected in the select box. For a complete listing of properties and methods, see the The Core API page. It's also recommend to review the Examples area for sample code. Accessing Native Form Objects if( objForm.Action.getValue() == "Edit" ){ objForm.obj.action = "edit.cgi"; } else if( objForm.Action.getValue() == "Delete" ){ objForm.obj.action = "delete.cgi"; } This would check the value of the field "Action" and change the form's action statementthe page which the data will be posted tobased upon the value found in the field. The "obj" property is created for both form objects and field objects. The syntax is as follows: Form Properties These properties will work exactly as they would if you called them using the document.form[x] syntax. ![]() |
![]() |
![]() |