Current Document Window
Two popular methods of outputting text to the current document window are the write() and writeln () methods. These methods were used in most of the examples for this chapter. The write() method writes the assigned text as defined inside its parentheses, or the argument, to the document object's current window. In the following example, the write() method sends its argument to the current document's window:
document.write("Writing "ABC..." to the current document's window!");
The writeln() method gives the output a new twist by adding a new line after the output. Inside the write() method, you can include tags and special characters that enhance how the text is output to the object. Table 16.12 outlines the tags and special characters to be used with the write() method.
Table 16.12. write() Tag Characters
|Adds a new line||document.write("\n Adds a New Line! ");|
|Adds a tab||document.write("\t Adds a Tab! ");|
|Adds a carriage return||document.write("\r Adds a Carriage Return! ");|
|f||Adds a form feed||document.write("\f Adds a form feed!f");|
|Adds a backspace||document.write("\b Adds a backspace!");|
|Makes the text bold||document.write(" Makes text bold!<>");|
|Forces a new line||document.write(" Forces a new line!
|Forces a paragraph||document.write(" Forces a new paragraph!
Actually, most HTML tags can be used inside the write() method. You'll also notice that a backslash is used to escape out the character so that it can be output. To get command literals to output in this way, use the backslash to escape the command. To output a literal backslash, use two of them together, as in \ . If you use an HTML tag that requires the use of double quotes, you can use single quotes to set the write() method's argument:
The SRC tag requires double quotes to be used. Therefore, the single quotes are used to set the write() method's argument.
Dialog Boxes and Prompts
One of the best ways to communicate with the user in the user interface is through dialog boxes and prompts. These are very helpful when you need to generate text that pops up in small dialog boxes, separate from the current document's window, or to interact with the user.
The alert() Method
alert("Thank you! Your document has been submitted");
Figure 16.12. The alert dialog box in the browser.
All the special characters and HTML tags that are used with the write() method can also be used with the alert() method.
The prompt() Method
The prompt() method allows you to interact with the user by capturing data entered. This is similar to the input method in LotusScript or @Prompt in @Functions. The prompt() method creates a dialog box with an entry field and allows for a default value. The syntax is as follows :
The prompt() method also returns the user's input and can be stored in a variable. Here's how you might use the prompt() method:
Figure 16.13 shows how this code looks on a Web page when it is evaluated.
Figure 16.13. The prompt() dialog box in the browser.
The result looks like Figure 16.14 if the user selects the default answer of Yes to the question.
Figure 16.14. After the prompt() is processed in the browser.
To recap, use prompt() to capture user input and use alert() to display a message to the user.
Part I. Introduction to Release 6
Whats New in Release 6?
The Release 6 Object Store
The Integrated Development Environment
Part II. Foundations of Application Design
Advanced Form Design
Using Shared Resources in Domino Applications
Using the Page Designer
Adding Framesets to Domino Applications
Automating Your Application with Agents
Part III. Programming Domino Applications
Using the Formula Language
Real-World Examples Using the Formula Language
Writing LotusScript for Domino Applications
Real-World LotusScript Examples
Writing Java for Domino Applications
Real-World Java Examples
Enhancing Domino Applications for the Web
Part IV. Advanced Design Topics
Accessing Data with XML
Accessing Data with DECS and DCRs
Security and Domino Applications
Creating Workflow Applications
Analyzing Domino Applications
Part V. Appendices
Appendix A. HTML Reference
Appendix B. Domino URL Reference