
 | 

Finding focus in your Web forms
Tip submitted by
Larry Willis


Level: Intermediate
Works with: Domino
Updated: 07/01/2002

Related link:
More Tips from LDD | 
 | 
When a Domino form is rendered in a Web browser, no focus is set on any field in the form. Using JavaScript, you can set the focus (that is, place the cursor) in the first field of a Domino form. To set the focus of a new document or an existing document opened in Edit mode, you can use the fieldname.focus() JavaScript method in the onLoad event.
However, you cannot use this method when opening an existing document in Read mode. When you open an existing document in Read mode in a Web browser, the HTML source code does not include references to the individual field names. So when the fieldfocus() method attempts to run in the onLoad event, an error occurs because the field name is not defined in the Domino-generated HTML.
To avoid this problem, use the following lines of code in the onLoad event of the Domino form:
var f=document.forms[0]
if (f.FieldName){f.FieldName.focus()}
Substitute FieldName with the name of the first field of your form. When you open the form or document in Edit mode, the cursor will appear in the first field of the form. If you open the form or document in Read mode, the field FieldName does not appear in the HTML code, and the JavaScript code will not be executed.
SUBMIT YOUR TIPS! |
We encourage you to send us your tips (You can also click the "Would you like to submit a tip?" graphic below.) Your tips can be anything you've discovered about any Lotus product. The most important thing is that your tip be interesting, useful, or handy. And be sure to include complete information about how your tip works. For ideas, take a look at our tip archives. If we publish your tip, we'll send you the IBM Redbooks Lotus Collection on CD. |
|
| 
 |