Examples: JavaScript events
- This form onLoad event sets the value of the Status field to "open" when a document loads. It works in a browser and the Notes client.
document.forms[0].Status.value = "open"
- This version of the onLoad event solicits a value for the Status field.
reply = prompt("Status = 'Open' or 'Closed'?", "Open") while (reply != "Open" && reply != "Closed") { reply = prompt("Enter 'Open' or 'Closed'", "Open") } document.forms[0].Status.value = reply
- This Status field onBlur event prevents the user from exiting the field without entering "Open" or "Closed." It works in a browser and the Notes client.
r = document.forms[0].Status.value while (r != "Open" && r != "Closed") { r = prompt("Status must be 'Open' or 'Closed'", "Open") } document.forms[0].Status.value = r
- The code shown in the last example could be placed instead in the onSubmit event. An action or hotspot containing the following @commands activates the code.
@Command([FileSave]); @Command([FileCloseWindow])
- This function is placed in the JSHeader event of a form.
function testEvent(eventName) { alert("This is the " + eventName + " event") }
The function executes whenever another event on the form (including a field, action, or hotspot) calls it, for example:
TestEvent("onLoad")