Writing event handlers for items on forms

You can code JavaScript and PL/SQL event handlers to customize the layout and operation of items on forms in sophisticated ways:

Refer to your JavaScript and PL/SQL documentation for descriptions of the events that are available to you in Oracle Portal.

Note: the version of JavaScript that you use must be supported by your browser.

An in-depth knowledge of JavaScript and PL/SQL is required to successfully include event handlers in your forms.

If you code both a JavaScript event handler and a PL/SQL event handler for the same button, be careful to avoid potential conflicts between the execution of the two scripts.

To write a JavaScript event handler for an item on a form:

  1. On the Oracle Portal Home page, click on the shortcut bar.

  2. Click the providers tab in the Oracle Portal Navigator.

    The Name column of the Navigator displays the names of all providers in which you have privileges to build database portlets.

  3. Open an existing form or create a new form that includes the item for which you want to write an event handler:

  4. In the left frame, click the name of the button for which you want to write a JavaScript event handler.

  5. In the right frame, scroll to JavaScript Event Handlers.

  6. Choose the required event for the item from the list, and type the JavaScript to be executed when the event occurs.

Example 1. To convert a value in a text box or text area input field to upper case whenever the field loses focus, choose the onBlur event and type the following JavaScript:

this.value = this.value.toUpperCase();

Example 2. To add a confirmation when the end user clicks a button before submitting a form, choose the onClick event and type the following JavaScript:

return confirm('Are you sure you want to submit the form?');

This displays a prompt dialog where the end user can click OK or Cancel; clicking OK submits the form.

Example 3. To verify that a value entered by the end user is a number only, choose the onChange event and type the following JavaScript:

if (isNaN(this.value)) {
  alert('Please enter a valid number.');
}

For additional information about writing advanced JavaScript event handlers, see your browser's documentation.

To write a PL/SQL event handler for a button on a form:

  1. Follow steps 1-4 above.

  2. In the left frame, click the name of the button for which you want to write a PL/SQL event handler.

  3. In the right frame, scroll to PL/SQL Button Event Handler.

  4. To use a pre-defined event, choose the required event for the button from the list. To create a custom event, choose Custom, and type the associated PL/SQL code.

Related topics

What are forms?
What are Master-detail forms?