|
|
|
|
|
|
|
|
|
|
|
|
|
|
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. Roll over 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. Roll over 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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- Advertisement --
Find unused Lotus Notes groups and clean up your address book
Have you ever wanted to get rid of old Lotus Notes groups that were cluttering up your address book, but you weren't sure if they were used? Find Unused Groups can help.
Find Unused Groups will check your ACL, mail, multi purpose and server groups to help you determine if they are used, and who uses them.
Learn how to easily clean up your address book. |
-- Advertisement --
Struggling with exporting Notes data to spreadsheets? No More!
Try IntelliPRINT, The world's leading Reporting, Dashboards, and Analysis solution for Notes & Domino
- Don't spend unproductive time maintaining different versions of the same spreadsheet
- Preserve data integrity and security in multi-user environments
- Create reports in minutes INSIDE Notes
- Get freedom from iterative report requests, deliver self-serve capabilities
Experience Reporting, Dashboards, and Analysis INSIDE Notes.
Try IntelliPRINT NOW! |
|
|
|
|
|
|
|
|
|
|