Javascript – Oracle Apex Application Item value setting using javascript


I have an application item- APP_BRCODE (not a page item), if I access the value using &APP_BRCODE. I can retrieve the value, but I can't set the value using javasctipt. $s('APP_BRCODE',value) does not works

Best Solution

Javascript alone can only change the value of an item that has been rendered on the page - i.e. page items. To change the value of an application item requires a call to the database - either submitting the page or making an AJAX call. You can make an AJAX call from Javascript code something like this:

    { x01: my_var 
    { success: function( pData ) {
     dataType: "text"

This will set x01 to the value of variable my_var and call the AJAX callback (aka "on demand") PL/SQL process MY_PROCESS.

The PL/SQL process can then set the application item:

:APP_ITEM := apex_application.g_x01;

Seems like a lot of work? Maybe. Without knowing why you want to set an application item from Javascript it's hard to say whether this is worthwhile. You could just set a hidden page item instead?