Passing a value around JS for element Page JS does not

I have several lines being generated by the region of PL/SQL code that creates several objects of apex_item. An identifier unique is assigned to each element by adding the line number to a name, i.e. item_nbr_1, item_nbr_2, new_item_1, new_item_2, etc. The item_nbr_n column has a JS that are associated with onChange. Within the JS I get the line number and assign to a variable as in
<script type="text/javascript">
  function checkItem( pThis ) {
    var l_ndx = pThis.id.substring(9);
   $s('P1115_NDX', l_ndx);
    var l_itemnbr = $v('item_nbr_' + l_ndx);
.
.
.
This $s ('P1115_NDX', l_ndx); is it so I can keep the line number to view later if necessary. More on that later.

In the end, if the item_nbr is entered exactly matches one and a single item in our product list, the checkItem function makes a call AJAX to a level application process and passes the value entered in the field item_nbr generated dynamically, through the item_nbr and line number, alias l_ndx. The APA process. then fill other fields of the line identified by l_ndx, such as description, cost, price, etc.

If the item_nbr is entered corresponds to the first characters more of an element or does not match any at all, the user is presented with an area of search criteria with which they can modify the entered item_nbr and/or add other search criteria. On this area of search, the user also has the option to request that this item be sought by purchases and added to the list of products.

It all works well so far, with the use of a variety of functions in JS and AJAX calls. The problem is the process of a new element. If the user clicks on the button new item in the search criteria area, I want a JS call to check the new_item_n on the appropriate line. However, at this time I have more the line number to add to the 'new_item_' so that I can "check" the box.

So, back to the $s ('P1115_NDX', l_ndx); escaped to above. I show the point of P1115_NDX, so I can confirm that the value is used. However, the newItem function does not seem to be able to read the value of the page element:
  function newItem() {
    var l_ndx = $v('P1115_NDX');
/*    l_ndx = 5;*//* Test for correct operation if the value is hard coded. It works */
    alert("The index of the check box is " + l_ndx);
    $x('new_item_'+l_ndx).checked = true; /* This courtesy of Hari from Trying to Set an APEX_ITEM.CHECKBOX with JavaScript */
  }
With the hard-coded test line commented, the alert does not return a number and the check box is unchecked. When the test line is not commented, this code works fine.

Thus, the result is, how should I store and subsequently make reference to the number line which began a series of events?

Thanks, especially for reading this,

Gregory

Published by: Gregory Hansen on October 21, 2010 09:06

Gregory,

In your function newItem try to get use of the page variable value

var l_ndx = $x('P1115_NDX').innerHTML

Based on your statement:

Gregory Hansen wrote:
So, back to the $s ('P1115_NDX', l_ndx); escaped to above. I show the point of P1115_NDX, so I can confirm that the value is used. However, the newItem function does not seem to be able to read the value of the page element:

It seems that P1115_NDX is a display only element so you can see what is happening. In this case the above should work.

Note that if you switch to a hidden item I think you need to go back to the $v (without the .innerHTML) rating.

HTH
Brother

Tags: Database

Similar Questions

Maybe you are looking for