Expanding The API One of the key features of qForms is its expandable architecture. qForms was designed to be easily expanded to meet specific needs of a project or just to fit your organziation. Expansion methods are creating by attaching new prototypes to the existing constructors. In order to do that, you'll need to know the name of each constructor and what it does. qForm Constructor
Field Constructor
Creating The Prototype Functions function __setToday(){ dToday = new Date(); var today = (dToday.getMonth() + 1) + "/"; today += dToday.getDate() + "/" + dToday.getYear(); this.setValue(today); } Field.prototype.setToday = __setToday; We now have a new method we can use on our forms. For example, to set the field "Date" to today's date, we simple call our new setToday() method. For example:
The syntax we've used in this example for creating new prototypes is the compatible with JavaScript v1.1. There is for those of you more familiar with JavaScript, you'll know there's a shortcut version which looks like: Field.prototype.setToday = function (){ dToday = new Date(); var today = (dToday.getMonth() + 1) + "/"; today += dToday.getDate() + "/" + dToday.getYear(); this.setValue(today); } However, this method only works in JavaScript v1.2 and higher. Methods created this way will cause JavaScript errors in Netscape v3.0. If compatibility with v3.0 browsers is not a requirement you need to stick to, then using this syntax to create new methods will not cause any problems. |
||