This section contains the following topics:
See Also:"Understanding Validations"
When you reference an item, the best approach is to reference by ID. If you view the HTML source of an Oracle Application Express page in a Web browser, you would notice that all items have an id attribute. This id corresponds to the name of the item, not the item label. For example, if you create an item with the name
P1_FIRST_NAME and a label of
First Name, the ID will be P1_FIRST_NAME.
getElementById() to get and set item attributes and values. The following example demonstrates how to reference an item by ID and display its value in an alert box.
In the HTML Header attribute of the page
In a .js file in the page template
test function accessible from anywhere on the current page.
On the Workspace home page, click the Application Builder icon.
Select an application.
Select a page.
Under Page, click the Edit page attributes icon.
Scroll down to HTML Header.
Enter code into HTML Header and click Apply Changes.
For example, adding the following would test a function accessible from anywhere on the current page.
See Also:"HTML Header"
In Oracle Application Express, you can reference a
.js file loads on the first page view of your application and is then cached by the browser.
The following demonstrates how to include a
.js file in the header section of a page template. Note the line
script src= that appears in bold.
See Also:"Page Templates"
This example creates a function to confirm a delete action and then calls that function from a button. Note that the function optionally submits the page and sets the value of the internal variable
Delete, thus performing the deletion using a process that conditionally executes based on the value of the request.
Note that when you create the button, you would need to select Action Redirect to URL without submitting page. Then, you would specify a URL target such as the following:
confirmDelete('Would you like to perform this delete action?');
See Also:"Creating a Button Using a Wizard"