|
|
|
|
|
|
|
|
|
|
Getting started with JavaScript development in Domino (continued)
Figure A shows the JSHeader section of the Domino form being used. This is where all JavaScript to be placed in the HEAD section of an HTML form is placed. This replaces the old technique of using the $$HTMLHead field, but that is still supported. I have placed a small function in the programmer pane in the screenshot.
FIGURE A
This Domino form is using the JSHeader section. Click picture for a larger image.
In addition to supporting JavaScript, the Domino Designer client will check the syntax of your JavaScript code as well. Of course, it cannot check logic so we programmers still have a bit of work to do.
Another excellent addition to Domino Designer R5 is a JavaScript object reference for both Web and Notes clients in the Object Browser pane. Figure B demonstrates the Object Browser for the Notes client.
FIGURE B
Domino 5.0 has a nice JavaScript Object Browser. Click picture for a larger image.
D.O.M. stands for Document Object Model, and it refers to the object model for the Web or Notes client. The drop-down list under the reference tab allows us to select the Web D.O.M or the Notes D.O.M. Objects in either client consist of such items as fields, dates, browser plug-ins, or the base window object.
Common applications One of the most common uses of JavaScript is field validation. A common text field can be checked with the following code (the following checks if the field is empty):
if (document.forms[0].fieldName.value == "")
{
alert("Please enter a value for the field.");
}
|
The validation of data can be used to stop the submission of a form. You don't want to save a document until it has been properly completed, do you?
You can place a validation function in the header (JSHeader) section of the form:
function validate()
{
var doc = document.forms[0];
if (doc.fieldName == "")
{
alert("Please complete the field before submitting.");
}
else
{
doc.submit();
}
}
|
The function named validate() will only submit the document when the field has been filled. You should use the submit method of the JavaScript document object in the else phrase. Now, you can add a link called submit. The link will reference your validate function, and submit the document if appropriate. Here is the formula for a link field (note: pass-thru HTML is used):
url := "JavaScript: submitdocument()";
"[<a href=\"" + url + "\">]" + "Submit Entry" + "[</a>] "
|
Another common use is setting default field values; the follow JavaScript code can be added to the JSHeader (or $$HTMLHead section for 4.6 users) section.
var doc = document.forms[0];
doc.firstName = "Denise";
doc.lastName = "Amrich";
|
The JSHeader or HEAD portion of a form is calculated first when a form is loaded, so our code populates the firstName and lastName fields on our form.
[ Prev | Next ]
|
|
|
|
|
|
-- Advertisement --
AUTOMATE LOTUS NOTES USER ID MANAGEMENT
ID Manager 4.5 from HELP Software provides a new level of automaton for managing Lotus Notes IDs. ID Manager lets Lotus Notes administrators get out of the business of creating and managing user IDs. Use our ROI calculator to see how quickly ID Manager will pay for itself.
Learn more about HELP Software products |
-- Advertisement --
Now for the first time, real-time dashboards within Notes!
No more tedious report iteration and endless data exporting! The New IntelliPRINT Dashboard Reporting now empowers you to easily create analyzable widgets and real-time dashboard reports. Your business managers can then quickly customize, extend, and analyze these dashboards to their heart's content!
All from within your Lotus Notes data, all in real-time!
Download your Free Trial today! |
|
|
|
|
|
|
|
|