This post illustrates an example where we wanted to lookup a value (called IMD Rank) based on the Postcode entered in another field. Users can either enter it manually, or click on a 'Lookup' button next to the field.
Firstly, define your process that will calculate the required value. This is most easily achieved by creating an Application Process (under Shared Components) which will run 'on demand'.
This PL/SQL is just retrieving a value (RANKOFIMD) from a table based on a page item (P27_P9_POSTCODE). Note the 'htp.prn()' function call which will actually 'send' the result to our page.
Note : it is OK to append this script to any code which may already be in this field.
Clicking on the Lookup button now populates the field based on the value retrieved by the GetIMD application process.