Search code examples
additionoracle-apexselectlistregions

Dynamically add fields based on select list apex 4.2


I'm developing in apex 4.2 and currently I'm having some issues with my form. I want to (dynamically) add textfields/regions based on the number that is selected in a selectlist.

So when I select 6, i want to see 6 regions with the same kind of textfields in it. Now i've made 6 regions myself and I have added some show/hide dynamic actions on it, but isn't there some kind of way to do this without having to manually add regions ?


Solution

  • I think you should create a process on your page when a button is pressed and run this PL/SQL anonymous procedure

    BEGIN
    FOR i IN 1..limit LOOP
    APEX_ITEM.TEXT(P_IDX        => 1,
       p_value      =>'array element '||i ,
       p_size       =>32,
       p_maxlength  =>32);
    END LOOP;
    END;
    

    the variable "limit" is catched from you're select list. this example is for creating textfileds dynamicaly althougth you can what ever item you want from the APEX_ITEM API , so here is the link http://docs.oracle.com/cd/E37097_01/doc.42/e35127/apex_item.htm#AEAPI192.