Example: Cascading Popup LOVs (Solution using Ajax)

If you need popup LOVs to depend on each other, here's a way to do it:
Put this in the header text of the page:
<script type="text/javascript">
function clearFormData(data) {
var items = new Array();
items.push(data);
for (var i = 0; i < items.length;i++) {
var item = items;
document.getElementById(item).value = '';
if (document.getElementById(item+'_HIDDENVALUE')) document.getElementById(item+'_HIDDENVALUE').value = '';
return true;
function setSessionData(data) {
var get = new htmldb_Get(null,document.getElementById('pFlowId').value,null);
var items = new Array();
items.push(data);
for (var i = 0;i < items.length;i++) {
var item = items[i];
var tempObjID = (document.getElementById(item+'_HIDDENVALUE')) ? item+'_HIDDENVALUE' : item;
get.add(item, document.getElementById(tempObjID).value);
get.get();
return true;
</script>
These are some helper functions (makes it easier to port to other pages, you could also put them in an external js file).
Now on the second (or whatever) popup LOV (one that needs the value of another), put following code into the field "Form Element Option Attributes":
[i]onclick="setSessionData('P1_FIRST_POPUP')"
Change "P1_FIRST_POPUP" into the id/name of the popup LOV that the second depends on.
Now to clear the second one (if there is already something in it) you can put this into the "Form Element Option Attributes" field of the first popup LOV:
onclick="clearFormData('P1_SECOND_POPUP')"
Change the "P1_SECOND_POPUP" into the id/name of the popup LOV that depends on the first one.
If you need more than one item to be set in the session use the javascript functions like this:
onclick="setSessionData(['P1_FIRST_POPUP','ANOTHER_ITEM';'AND_SO_ON'])"
onclick="clearFormData(['P1_SECOND_POPUP','ANOTHER_ITEM';'AND_SO_ON'])"
This is the best solution I figured out so far for cascading popups.
Demo: http://apex.oracle.com/pls/otn/f?p=36908:2
If you need cascading select boxes it's better to use this solution: http://apex.oracle.com/pls/otn/f?p=11933:37 .
Edit:
- works now regardless of being logged in or not, I just forgot to take ou the 0 in the htmldb_Get call (=> always
sent the session id "0", which didn't exist)
- added a link to the demonstration

excellent tip for using ajax to update session state.
one small change to share:
function setSessionData() {
var get = new htmldb_Get(null,document.getElementById('pFlowId').value,null,null);
for (var i = 0; i < arguments.length; i++) {
var item = arguments\[i\];
var tempObjID = (document.getElementById(item+'_HIDDENVALUE')) ? item+'_HIDDENVALUE' : item;
get.add(item, document.getElementById(tempObjID).value);
get.get();
return true;
set 4th argument to htmldb_Get constructor to null.. causes the script to retrieve the value from the hidden form field, rather than being set explicitely.
just noticed this code is different from the demo, which does set a static value of 2. Tempted to hit cancel, but maybe this can avoid someone else a lot of head scratching.
also, was having issues with Array.push() during debugging to find the above issue.. and changed the way html form element id(s) are passed to the function; opted to use the implicit "arguments" array instead. Minor, but worth noting.
thanks again for the useful piece of code.
edit:
this wiki doesn't parse brackets well; added char escapes so they'll show.. will need to remove by hand.

Similar Messages

  • Help needed in Cascading Popup LOV

    Hi,
    I have 2 popup LOV in my APEX Page as LOV1 , LOV2. I am currently using "Popup LOV (fetches first rowset)".
    My requirement is ,until I select a value in LOV1 , LOV2 must be in disabled state. As soon as I get value in LOV1, based on that value, LOV2 must be populated and should change to enabled state.
    I am not sure how this can be implemented or whether it can be implemented in APEX.
    Any suggestions please. Do I have to change Popup LOV type, how to submit the page when LOV1 is selected etc.
    I am a beginner in APEX. Any suggestions would be welcome.
    Thanks
    Alaka

    Hi,
    Thanks for the reply..
    I will try this.
    It would be better if anyone tells me, how can I disable the LOV and enable it after I select the LOV1.
    Thanks
    Alaka

  • Select lists empty or POPup LOV needed with redirect

    Hi all,
    I have a form where i need 6 select lists with redirect or 6 POPup LOV with redirects.
    These select lists are separated in three groups
    like this
    group 1
    departments select list with redirect
    employees popup lov (query based on the value of department)
    group2
    Order select list with redirect
    OrderItem popup lov but needs a redirect here for employees (query based on the value of countries)
    employees popup lov (query based on the value of department)
    group 3
    some status select list with redirect
    When I choose the first select list the popup LOV is populated with good values
    when i select a value from the second select list the value in the first list disappears, including the value of the first popup lov. etc.
    How is it possible to keep the values stored in the first selects list when selecting some value of the second list.
    How is is possible to make a popup lov with redirect so that the values are in session
    and can be used in another popup lov?
    Is someone there who have experiences with this issue?
    thanks in advance,
    Hugo

    Hi Hugo,
    I don't think that you need a redirect for that. Check out my AJAX cascading popup lov solution.
    http://inside-apex.blogspot.com/2006/11/generic-solution-for-depending-select.html
    Hope this helps
    Patrick
    Check out my APEX-blog: http://inside-apex.blogspot.com

  • Passing Request to a POPUP LOV from previous page

    Hi All,
    I'm stuck again :( and its urgent..
    I have a popup LOV and i want to populate values in it based on REQUEST coming from first page.
    If I click CREATE on first page POPUP LOV should display certain values and if I click UPDATE on first page, it should populate different set of values.
    Also when I navigate further from this page and return back, the LOV's should have values based on previous request selected.
    For this I have created an item P_REQ which stores value of request from first page i.e :P_REQ wil have values CREATE or UPDATE.
    Now I'm able to pass this value to a select list. However a POPUP list is not able to fetch this P_REQ value.
    MY query for LOV is as below
    select d1 d ,r1 r
    from
    (select name d1 ,ID r1,'C' up_cr
    FROM Client
    'WHERE statusid in (1,3)
    union
    select name d1,ClientID r1,'U' up_cr
    FROM Client_List)
    where up_cr = decode(:P_REQ,'CREATE','C','U')
    ORDER BY d1
    Kindly help.. Its Urgent..

    Hi,
    If you use that computation to set the value of P_REQ it is actually also saving it in the session. The value stored can then be retrieved by the popup LOVs query using :P_REQ so you don't need to pass the value at all as it is already available.
    To see this, go to: [http://apex.oracle.com/pls/otn/f?p=33642:237] The list of employees has INSERT or UPDATE in the final column. This is used in the link on the EMPNO column as the "Request" setting. This link passes you to another page which uses the computation to set the value in P238_REQUEST (this is displayed on the screen). Then you have a link to "Open popup". All this does is open another page which has a region with a source of: Request value: &P238_REQUEST.
    Andy

  • APEX 4.0 - AJAX not working with Popup LOV field

    Hello,
    In the application I have built I have three fields which are 'feeded' by selects via a AJAX construction.
    All three fields are based on three others, which are PopUp LOV fields. Up to version 3.2 I had no problems: the fields were 'refreshed' as expected when in the 'parent' field a specific value was entered or choosen by the Popup Lov selector.
    But since the migration to APEX-4 (lin a test-system) all the three fields are not correctly refreshed anymore: two of them give the value 'undefined', the third, which is a select-list shows values, but at the moment I try to click on the select-list down arrow to pick a value, the list is emptied and stays that way.
    More specific about the third field:
    item 1 is a popup-lov defined item in which a user can type a value, but can also choose a value from a popup-lov. Item 2 is based on item-1: it does a select based on the value of item-1 and refreshes a select-list. Item-2 is defined as a select list.
    I got it all working when making item-1 also a select list, but since the list can become very large, I made a Popup lov of it. Most users do know what code they have to enter and in case somebody is not sure, the lov can be used.
    In this forum I came across a problem with AJAX callback, which was answered by Patrick Wolf, saying that in an htmldb_Get ( ... ,0) the last 0 should be replaced by $v('pFlowStepId'), but this did not fix my problem. I have the feeling that the problem is somewhre else, since on first hand, after entering a value in item-1 I see item-2 refreshed with the correct values, but the moment I try to select one item, the list is emptied.....
    I hope I made it clear what my problem is and that somebody can help me, else APEX-3.2 was the latest version for this application....
    Thanks in advance and best regards,
    Jan.
    Edited by: user13110728 on 9-aug-2010 8:44

    Hi Jan,
    the problem is the
    onBlur="javascript:f_P21_select_kostenposten(this,'P21_KOSTENPOST');"on P21_GBREKNR. This is getting attached to the HTML input text field but as well the the anchor link which opens the popup. So when you leave the text field the cursor will be put onto the icon to open the Popup LOV. When you press tab another time or leave the anchor link by clicking somewhere the above JavaScript function is fired again. But the problem is that "this" this time points to the anchor and not the text item anymore, so it will return an invalid value when you access this.value in your f_P21_select_kostenposten function which results in an empty result of your on-demand call.
    I still have to investigate why the above JavaScript code is now added to the anchor link as well. But as a workaround, just change your code to
    onChange="javascript:f_P21_select_kostenposten(this,'P21_KOSTENPOST');"which is better anyway, because it's just firing when the value really got changed. And because the anchor link can't really be changed, the event will never fire when you leave the anchor. BTW you can use the Application Search feature to search for all your onBlur events. onChange is much better than onBlur because it doesn't fire that often unintended.
    But if you want to use some of the new APEX 4.0 features, you could use the cascading LOV feature of APEX 4 and avoid all this JavaScript and on-demand code which you have written.
    I have changed your application to take use of it.
    1) I changed the LOV query for P21_KOSTENPOST from
    select '('||replace(lpad(gbreknr, 3, chr(1)),chr(1),' ')||') '|| omschrijving d, kostenpost r
    from   kostenposten
    where  vervallen is null
      and  bedrijf = :P21_BEDRIJF
    order by gbreknr, kostenpostto
    select '('||replace(lpad(gbreknr, 3, chr(1)),chr(1),' ')||') '|| omschrijving d, kostenpost r
    from   kostenposten
    where  vervallen is null
      and  bedrijf = :P21_BEDRIJF
      and  (:P21_GBREKNR is null or gbreknr = :P21_GBREKNR)
    order by gbreknr, kostenpostas it was in your on-demand process. The query will return all values if P21_GBREKNR is null but will restrict it if the field is filled out.
    2) Set "Cascading LOV Parent Item(s)" to P21_BEDRIJF,P21_GBREKNR Because based on your LOV query I assume "Kostenpost" should be refreshed if one of the two fields gets changed.
    3) Set "Optimize Refresh" to No because one of your parent items (P21_GBREKNR) can contain a null value.
    4) Removed the onBlur/onChange from P21_GBREKNR
    5) Removed the *%null%* from the "Null Return Value" attribute of P21_BEDRIJF, because that will cause a ORA-1722 if someone picks "-- kies: --"
    That's it.
    Have a look at dynamic actions and the "Set Value" action as well, because I think that could remove your other on-demand calls as well without having to write any JavaScript code.
    I will still investigate what's going on with the anchor link in APEX 4.0
    Regards
    Patrick
    My Blog: http://www.inside-oracle-apex.com
    APEX 4.0 Plug-Ins: http://apex.oracle.com/plugins

  • Popup LOV fails in firefox when using an outer join!!!

    I have a popup lov which contains at least 2 outer joins in my query. The popup renders fine in IE but i get the error message:
    "Popup List of Values query is invalid, a display and a return value are needed, the column names need to be different"
    when launching the popup from Firefox (1.5.0.2)
    Anyone got any idea why this works in IE but fails in Firefox?
    Cheers
    Duncan

    Hello,
    Duncan – If you'll run your example code on SQL*Plus, you'll see that for department "OPERATIONS" there is no returned value. This could happen with outer join. The problem can be with the way FF is interpreting this non-value. I didn't try it my self, but maybe if you'll use display null value with your LOV, it will solve the problem. Another possible option is to use NVL() on the returned value.
    Chris – Some of the Apex team members, like Carl, are using FF as their main browser. There are some compatibility issues with the last version of FF, but from that, to your conclusion of Apex only support IE, there's a long road.
    Regards,
    Arie.

  • Using Union in popup LOV

    HI,
    I want to select data from 2 tables using Union in Popup LOV ,
    please help.
    I am getting a error message like
    "LOV query is invalid, a display and a return value are needed, the column names need to be different. If your query contains an in-line query, the first FROM clause in the SQL statement must not belong to the in-line query."
    when i use union query
    my query is like this
    select a from table 1
    union
    select b from table 2
    order by a;

    Hi,
    Three things -
    1) Remove the semi-colon from the end of your query (it can work without it, but you'll eventually run into problems some day by putting a semi-colon on the end, so better to get into the habit of not doing it).
    2) You need to provide 2 columns in your query, a display value and a return value (look at the error message you are getting). You are only returning a single column.
    3) Wrap your query inside another query to get it to work.
    Something like this should work -
    select * from (
      select 1 as r, 2 as d from dual
      union
      select 3 as r, 4 as d from dual)
    order by dObviously change the values/columns to suit your own purposes.
    Hope this helps,
    John.

  • Is there a problem using popup LOVs in a portal form with a bind variable?

    I have a portal form with 2 LOVs. The second LOV is a dependent LOV whose bind variable can be NULL. I have read Note 263923.1, "How To Create Dependent Lovs In Forms", and my form works as long as I use combo boxes to display the LOVs. I need to use popups so the user can search the LOVs as they are quite lengthy. Plus I want to be able to pick a value from my second LOV without selecting a value from the first LOV -- hence, my bind variable can be null and that is where my problem lies. As long as I select a value from the first LOV, the second LOV popup will work. If I click on the icon to display the second LOV without pre-selected a value from the first LOV, I get the following error:
    POPUP LOV ERROR:
    LOV: "9A17692880B6B8509F514F5B9CA9EC808DD403218B3CF19A33C04CD1FAB0ADE17ADC33E6B67998A933357CE5264D204E"
    Parse Message: Parse as pre-set global: "TORE".
    Find Message: LOV is of type DYNAMIC (LOV based on SQL query).
    Query: "SELECT ...."
    wwv_bind.prepare_bind: ORA-01403: no data found
    My form is based on a table with a custom layout. The sql for the second LOV is similar to: SELECT ENAME, EMPNO FROM SCOTT.EMP WHERE (DEPTNO = :DEPT AND :DEPT IS NOT NULL) OR :DEPT IS NULL.
    Thanks in advance for any help,
    Carol

    Don't use EPS any more! It does not support transparency nor color management.
    If you save vector files from Illustrator, use AI with PDF compatiblity.
    If you save image files from Photoshop, use PSD.
    If you save image files combined with vector forms and/or text from Photoshop, use PDP which is a Photoshop PDF.
    For vectors from Illustrator use CMYK files.
    For images use RGB, conversion to CMYK should never done before PDF export, better, if the printer allows it, is to export a PDF with live transparency as it is PDF/X-4
    If the printer requires a PDF with CMYK only export a PDF/X-1a.

  • Disabled button of popup lov

    hello, i have a popup lov.
    i need to disabled this item
    but if a user click on the button associate to popup lov the value is changed
    how i can disabled this button?
    thanks
    Daniel

    Daniel,
    It's actually not a button at all. It's an anchor tag that displays an image. The href attribute of the anchor tag is the key - it makes a JavaScript call. If you're ok using jQuery for the solution I'd be happy to put one together for you. Put up an example application on apex.oracle.com. Let me know the workspace/username/password you want me to use...
    Regards,
    Dan
    http://danielmcghan.us
    http://sourceforge.net/projects/tapigen
    http://sourceforge.net/projects/plrecur

  • Popup LOV Returning Values

    In my entry form I'd like to use the "Popup LOV" to bring the names of employees. I use the following statement:
    SELECT full_name, party_id
    FROM vs_parties
    ORDER BY 1
    Everything seems to be working OK, however, only "party_id" is returned to the form. Is there a way I can hide the ID field and display the related "full_name" only.
    Regards, Tomas

    In order to clear out a Popup Key LOV value it was suggested to ..... Preface the query with [select '-choose option-' a, 0 b from dual union all ...].
    Does anyone know of a fix for this solution if you want to set the value to null? Because as it stands if you use this query and replace "0" with null, the popup key lov actually returns "-choose option-" for both the display value and the actual value. I cannot use the value of "0" so that is why I am needing it to return as null.
    Here is an example I posted up, the field that has the Popup key is "Name" you will see that once you pick "choose option" and save the record that in the report it sets the value of name to "-choose option" instead of null. Once this happens you cannot edit the record unless you do a backend SQL update to set value to null or a anything else.
    Here is the link: http://htmldb.oracle.com/pls/otn/f?p=37103:21
    This is the LOV query used for Name:
    select '-choose option-' a, null b from dual union all select IP a, ip_id b from IP order by a

  • Dynamically load Popup LOV

    <p>I need to load a Popup LOV with values filtered by a previous selection in a standard Select List. I need to do it without submitting the page to place the filtering LOV's value into session state (I've got other things happening on submit). </p>
    <p>I've used Carl's cool AJAX solution for standard Select Lists. Is there a similar method that will work when the target LOV is a Popup?</p>
    <p>thanks, </p>
    Mark

    A select list (dropdown) is part of the page when it is rendered, that is why the AJAX stuff is needed to replace the dependent dropdown lists.
    With popup LOVs, it is much simpler because the popup LOV query is not run until you click on the popup icon.
    If the popup LOV query refers to session state (:P1_ITEM), all you need to do is set the session state using the AJAX snippet.
    Put onchange="foo(this);" into the HTML Form Element attributes of the first select list (say P1_ITEM) and use something like
    function foo(pSelect)
    var l_select=html_SelectValue(pSelect);
    var get=new htmldb_Get(null,html_GetElement('pFlowId').value,'APPLICATION_PROCESS=null',0);
    get.add('P1_ITEM',l_select);
    get.get();
    get=null;
    }"null" is a on-demand Application Process that does nothing. A PL/SQL block with just "null;"
    That's it. Now when you click on the popup LOV, it will get the latest value of P1_ITEM in session state in its defining query.
    Hope this helps.

  • Hiding of Popup lov(fetches first rowset)

    Hi all,
    I want one solution,How can i hide popup lov(fetches first rowset),Using javascripts.Can anybody helps me with this.
    Thanks

    user632863,
    Please, have a look at the example again:
    http://apex.oracle.com/pls/otn/f?p=31517:129
    There is a popup LOV and it will be hidden depending on what you choose from the radio button. The trick is in using the proper function for hiding not only an element but the entire row.
    I think this answers your question. Please, read the code explanation underneath.
    Denes Kubicek
    http://deneskubicek.blogspot.com/
    http://www.opal-consulting.de/training
    http://apex.oracle.com/pls/otn/f?p=31517:1
    -------------------------------------------------------------------

  • Three multiselect lists using AJAX

    I have an application with 3 multiselect (ms) lists. Selecting one or many items from the first ms list should create a 2nd list of values based on the selection(s) in the 1st ms list. A 3rd ms list should then be created based on the selection(s) from the 2nd ms list. The selection(s) in the 3rd ms list are then used to create a report based on those selections.
    I'd like to be able to do this using AJAX. I've created an AJAX process to do this using single selections but not multiple selections (following Carl Backstrom's examples).
    Any help would be appreciated.
    Thanks,
    John

    Hi,
    I also played a little bit around, having a multi select list as master.
    The outcome was that the framework didn't support it, because
    -) the value attribute of a multi-select-list just returns the first selected entry
    -) APEX is having a problem if a colon is contained in an AJAX request
    But the good news is that after some corrections the framework is now able to support multi-select-lists as a master of a cascading lov! :-)
    Write me an e-mail to get the newest files for the framework.
    Patrick
    Check out my APEX-blog: http://inside-apex.blogspot.com
    Check out the ApexLib Framework: http://apexlib.sourceforge.net

  • Theme 23 does not display popup LOV in tabular form

    I created new application using new Theme 23. In tabular form the popup LOV button does not show. While using this theme the column LOV button is soooooo small it is not visible. If I move the cursor on the side of the field eventually I cursor handle will change and I can click and popup LOV will show. When I switch to an older theme (e.g. 21) the LOV button shows just fine.
    Does anyone can offer a solution? Can I expect more this type of problems in the new theme 23?

    I examined exported application file. Indeed the problem is p_column_id parameter. It should be decimal number for translated application. Characters %2C in p_column_id value stands for comma. It should be dot instead. Parameter value should be p_column_id=30289208519476123679.915121.

  • How to get the value from one Popup lov column to another popup lov column

    Hi,
    I am new to oracle apex development and having the below issue.
    In my application, there is a tabular form with 15 columns ( c1.. c15).
    I have to populate the value of column C5 based on the selected(from popup lov) value of column C3, tried to use onchange, but didn't help much.
    Any help please.
    Thanks and Regards,

    Oh boy, this is a fun one.
    onchange should work theoretically (in this example, assume that f05 is the target column that should be set and "this" is the source item whose value is to be transferred to f05 on the same row (row 2)):
    onchange=$s('f05_0002',$v(this));
    BUT the catch is of course that needs to be different for every row (can't hardcode the '2'), so you need something to dynamically create the row number component.
    I wrote this for an app I'm working on that uses master-detail forms heavily (I also wrote a lot more code to read the fmap array that is in v4 so that I can reference my cells via their column name and not the numeric position (so "f05 can be determined w/o hard coding), insulating against columns moving around, columns being made display-only etc. but I won't bore you with that here unless you really need to know).
    function getRow(pObj)
    { //Pass in an object reference to a tabular form cell and get back an integer
      //derived from the object ID.
      var vRow=pObj.id.substr(pObj.id.indexOf("_")+1);
      if (isNaN(vRow))
        return (null);
      return (parseInt(vRow,10));
    function formatRow(pRow)
    { //Pass in an integer and it'll be returned as the tabular form cell ID suffix
      //(e.g.: pass in 1 and get back string "_0001").
      //Used in building ID references to tabular form cells.
      if((isThingEmpty(pRow)) || (isNaN(pRow)))
        return(null);
      var vRow=pRow.toString();
      while(vRow.length<4)
        vRow="0"+vRow;
      return("_"+vRow);
    }Therefore:
    onchange=$s('f05_'+formatRow(getRow(this)),$v(this));
    So in essence, pass in "this" which will be a reference to the current item, largely to determine what row we're on. getRow will return 1, 2, 3, etc. formatRow will take that and return 0001, 0002, 0003, etc. Once that is done, it'll concatenate with the f05 and f04 to refer to the correct columns (determining f05, f04, etc. dynamically is another matter if you really need to but I didn't want to complicate this answer too much at once).
    Note: above I also use a isThingEmpty() function that I wrote. It does nothing other than check the item for an empty string, if the item is null, etc. Just do your own evaluation of empty-string, no-value, etc. there.
    It would indeed be nice though if Apex had a better way to delclaratively access the tabular form items though. Despite all the v4 enhancements, tabular forms were not entirely upgraded to the same full functionality of page items.

Maybe you are looking for

  • Work center for Production order

    Hi, In my report I need to link the production order to work center. I have got all the information for the production order from AFKO, but I am unable to find a way to link it to the work center? Thanks Vamsi

  • Printing Black squares

    Hi, Every time I try and print a photo in Aperture 2.1 to my Epson colour laser printer all I get is a black square the size of the photo, with the crop marks. I never had this problem in Aperture 1.xx. I've tried exporting the image to a pdf and pri

  • Rebate Agreement :SDBONT06

    Hi , I am using ECC 6.0 and have configured rebate agreement . In VBO2 in am getting an Information massage "The sales volume for agreement  is not current". I run the program "SDBONT06" (Transaction Code:VBOF)for updating the sales volume for the ag

  • Adobe Download Assistant doesn't show me CS6 Design Standard as an option. Why?

    Adobe Download Assistant doesn't show me CS6 Design Standard as an option. Why?

  • Java Object Factories

    Hi, I'm learning about the use of Java Object Factories, are there any good links or tutorials that cover this topic? I have already read through the trail written by Sun on Java Object Factories. Am I right to say that with Object Factories, given t