Posted by : Akshay Patil Monday 16 March 2015

The Apex JavaScript API has some very convenient functions to access the values of page items.

For example, if you wante to access the contents of a text field with JavaScript, would need to reference it something like this:
$x("P7_TEXT_FIELD").value;
or
$("#P7_TEXT_FIELD").val();

If the item you want to reference is a display only item, then the syntax changes:
x = $("#P7_DISPLAY_ONLY").text();

If you need to set the values of these items, the you need to use the varying syntax as well:
$x("P7_TEXT_FIELD").value = "Hello World!";
or
$('#P7_TEXT_FIELD').val("Hello World!");
or
$("#P7_DISPLAY_ONLY").text("Hello World!");


Dealing with these various syntax constructs can be confusing. Fortunately the Apex JavaScript API makes this process much easier. To get page item values simply use $v(“<item_name>”):

x = $v("P7_TEXT_FIELD");
y = $v("P7_DISPLAY_ONLY");
To set the item values use:

$s("P7_TEXT_FIELD","Hello World!");
$s("P7_DISPLAY_ONLY","Hello World!");
See an example on my demo page.

The $v2() is handy if you need to access multiple items in an array. For example multiple selections from check boxes or from a shuttle control can be fetched as an array and handled that way in JavaScript:

myArr = $v2("P7_SHUTTLE_CONTROL");
for (idx=0; idx<myArr.length; idx++) {
  //do something with myArr[idx];
}

{ 3 comments... read them below or Comment }

  1. Hi,
    i have this javascript funcion called on KeyUp:
    function verifyIBAN(pThis){
    var iban = pThis.value;

    var ajaxCall = new htmldb_Get('P3_VERIFYIBAN',&APP_ID.,'APPLICATION_PROCESS=VERIFY_IBAN',&APP_PAGE_ID.);

    // Images with cancel and confirm image
    document.getElementById("P3_IBAN_NOTOK").style.visibility = "hidden";
    document.getElementById("P3_IBAN_OK").style.visibility = "hidden";

    // call pl/sql function that returns OK / NOT OK
    ajaxCall.addParam('x01',iban);
    var gReturn = ajaxCall.get(); // esegue la chiamata a Verify Iban

    // This if goes always in else

    if ($v("P3_VERIFYIBAN") == "OK"){
    document.getElementById("P3_IBAN_OK").style.visibility = "visible";
    } else {
    document.getElementById("P3_IBAN_NOTOK").style.visibility = "visible";
    }
    }

    It seems that the javascript is unable to get P3_VERIFYIBAN value (it's a display only field)
    Please help.

    Thanks in advance.

    Br
    Giulio

    ReplyDelete
  2. function run_att() {

    var x_val = $v("A_QUARTER");
    var vurl ='http://10.10.50.249:8889/reports/rwservlet?userlogin&report=c:/senior/attendance_summary_1st.rdf&semester='+$v('A_SEMESTER')+'&section='+$v('A_SECTION')+'&period='+$v('A_TERM');
    var vurl2 ='http://10.10.50.249:8889/reports/rwservlet?userlogin&report=c:/senior/attendance_summary_2nd.rdf&semester='+$v('A_SEMESTER')+'&section='+$v('A_SECTION')+'&period='+$v('A_TERM');

    if(x_val='M')
    window.open(vurl,'_blank');

    else
    window.open(vurl2,'_blank');

    }


    whats wrong with this java script?
    even i change the value of the item..
    still the first report openned..

    ReplyDelete
  3. Thanks for sharing this blog. The content is beneficial and useful. Very informative post. Visit here to learn more about Data Warehousing companies and Data analytics Companies. I am impressed by the information that you have on this blog. Thanks once more for all the details.Visit here for Top Big Data Companies.

    ReplyDelete

Welcome to My Blog

Study Basics

Oracle APEX Oracle SQL Oracle PL/SQL

Popular Post

Blogger templates

Total Pageviews

Powered by Blogger.

Unordered List

Follow us on Facebook!

- Copyright © TechnicalBits -Robotic Notes- Powered by Blogger - Designed by Johanes Djogan -