Thread: How to use multiselect list in tabular form


Permlink Replies: 21 - Pages: 2 [ 1 2 | Next ] - Last Post: May 18, 2007 11:17 AM Last Post By: VANJ
sgodavar

Posts: 381
Registered: 01/10/01
How to use multiselect list in tabular form
Posted: May 15, 2007 10:54 AM
Click to report abuse...   Click to reply to this thread Reply
I'm trying to get the multiple values from multiselct list in custom tablular form, but it returns only one value. I'm using the below statetment to display multislect list in each row of tabular form. I would appreciate your thoughts on how to set this item and process the the item to returm multiple values in the process.

HTMLDB_ITEM.SELECT_LIST_FROM_LOV_XL(3,name,''test_name'',''multiple size = "3");

thanks for your help,
surya
Dimitri Gielis

Posts: 1,859
Registered: 04/21/07
Re: How to use multiselect list in tabular form
Posted: May 15, 2007 12:09 PM   in response to: sgodavar in response to: sgodavar
Click to report abuse...   Click to reply to this thread Reply
Hi Surya,

Is it this what you try to do?: http://apex.shellprompt.net/pls/apex/f?p=286:9
I just made that example... this is my query:
SELECT "EMPNO", <other columns of emp table>, "COMM", "DEPTNO",
HTMLDB_ITEM.SELECT_LIST_FROM_LOV_XL(2,job,'JOB_LOV_D','multiple size = "3"') S_LOV_MSIZE_3
FROM "#OWNER#"."EMP"

JOB_LOV_D is an LOV which does a select of the jobs.

Hope this helps,
Dimitri
VANJ

Posts: 6,048
Registered: 03/18/04
Re: How to use multiselect list in tabular form
Posted: May 15, 2007 12:10 PM   in response to: sgodavar in response to: sgodavar
Click to report abuse...   Click to reply to this thread Reply
As you probably figured out, the multiselect list is rendered fine but when you select multiple items from it, the g_fNN arrays get confused. Instead of storing each entry g_f01(i) as a colon-delimited list of values, it creates multiple entries g_f01(1), g_f01(2) and there is no way to tell which entry belongs to which row on the tabular form.

Maybe someone from Oracle has some ideas, but I think this is not doable in APEX. Accept processing expects just 1 value per g_fNN array entry.

See http://apex.oracle.com/pls/otn/f?p=24317:13

Run the page in debug mode, select bunch of values from each select list, click Submit button and see the debug entries written by the process
for i in 1..apex_application.g_f01.count
loop
wwv_flow.debug('i='||i||',f01(i)='||apex_application.g_f01(i));
end loop;
sgodavar

Posts: 381
Registered: 01/10/01
Re: How to use multiselect list in tabular form
Posted: May 15, 2007 12:21 PM   in response to: Dimitri Gielis in response to: Dimitri Gielis
Click to report abuse...   Click to reply to this thread Reply
Hi Dimitri ,

thanks for your thoughts. The rendering part is fine, but when the page is submitted, it returns only one value, instead of multiple values selected in the LOV. I would appreciate if you could help me in getting the multiple values from this LOV.

Vikas - thanks for your input. I would appreciate if you could share any possible workarounds?

thanks for your help,
Surya
VANJ

Posts: 6,048
Registered: 03/18/04
Re: How to use multiselect list in tabular form
Posted: May 15, 2007 12:26 PM   in response to: sgodavar in response to: sgodavar
Click to report abuse...   Click to reply to this thread Reply
Well, the workaround is ugly.

You could

a. render a hidden apex_item.hidden(2,...) field on the tabular form.
b. Write some onClick Javascript on your multiselect list to take the selected value(s) of the multi-select list, concatenate them together using some delimiter and assign them to the hidden item
c. Use the hidden array apex_application.g_f02 in your accept processing, parse them on the delimiter and do whatever you need with the individual values

Like I said, not pretty!
Patrick Wolf

Posts: 1,812
Registered: 04/24/00
Re: How to use multiselect list in tabular form
Posted: May 15, 2007 12:42 PM   in response to: VANJ in response to: VANJ
Click to report abuse...   Click to reply to this thread Reply
Hi Surya,

was also looking into that. Vikas JavaScript suggestion seems to be the only solution for that.

Patrick

My APEX Blog: http://inside-apex.blogspot.com
The ApexLib Framework: http://apexlib.sourceforge.net
The APEX Builder Plugin: http://sourceforge.net/projects/apexplugin/
sgodavar

Posts: 381
Registered: 01/10/01
Re: How to use multiselect list in tabular form
Posted: May 15, 2007 12:54 PM   in response to: Patrick Wolf in response to: Patrick Wolf
Click to report abuse...   Click to reply to this thread Reply
thanks for valuable suggestions. I'm just wondering, if anyone has tried the javascript solution and works, wheather it is possible to share the solution. I really appreciate your help.

thanks,
Surya
VANJ

Posts: 6,048
Registered: 03/18/04
Re: How to use multiselect list in tabular form
Posted: May 15, 2007 1:34 PM   in response to: sgodavar in response to: sgodavar
Click to report abuse...   Click to reply to this thread Reply
See my little example page http://apex.oracle.com/pls/otn/f?p=24317:13

1. Run it in Debug mode, put YES in the Debug position in the f?p= URL
2. Select Two, Three, Four on the first row
3. Select Three, Four on the second row
4. Select Four on the third row

Click Submit.

You will see that the debug shows

0.07: i=1,f02(i)=TWO:THREE:FOUR
0.07: i=2,f02(i)=THREE:FOUR
0.07: i=3,f02(i)=FOUR
0.07: i=4,f02(i)=
0.07: i=5,f02(i)=
0.07: i=6,f02(i)=
0.07: i=7,f02(i)=
0.07: i=8,f02(i)=
0.07: i=9,f02(i)=
0.07: i=10,f02(i)=
0.07: i=11,f02(i)=

which is what you need. i.e. each entry in the f02 array contains a colon-delimited list of the multiple values you selected from the multi-select list.

The query is
select
empno,
apex_item.hidden(2,null)||
APEX_ITEM.SELECT_LIST_FROM_LOV(1,null,'SOME_LOV','multiple size = "6" onclick="Multi(this)"') lov
from emp_copy

The Javascript is

function Multi(p_this) 
{
var l_selected=html_SelectValue(p_this);
if (l_selected.constructor == Array) l_selected=l_selected.join(':');
p_this.parentNode.firstChild.value = l_selected;
}


Hope this helps.
sgodavar

Posts: 381
Registered: 01/10/01
Re: How to use multiselect list in tabular form
Posted: May 15, 2007 3:47 PM   in response to: VANJ in response to: VANJ
Click to report abuse...   Click to reply to this thread Reply
Vikas,

thank you very much for your help. "onClick" event was not able to trigger the javascirpt in both IE and mozilla, then I tried with "onChange" event, then it triggers the javascript function, but passes only one value to the function and the same one value is available in the array also for me to parse in the page process.

I just put this javascript statement to check the value passed to the function.

alert(p_this.value) and it prints one value eventhough multiple values are selected.

could you please throw some light on this?

thanks for your time and help,

Surya
VANJ

Posts: 6,048
Registered: 03/18/04
Re: How to use multiselect list in tabular form
Posted: May 15, 2007 4:27 PM   in response to: sgodavar in response to: sgodavar
Click to report abuse...   Click to reply to this thread Reply
My example works fine in Firefox. I am really not sure why it doesn't work in IE and its stupid idiosyncracies. Maybe someone else can extend the approach to work with IE.

Google for multi select list and onclick/onchange to see if IE has any quirks in this area

Update: Googling gave me http://www.digitalamit.com/blog/blog/23.html which suggests to use a onblur event instead. I changed my example to do that and it seems to work fine in IE.
sgodavar

Posts: 381
Registered: 01/10/01
Re: How to use multiselect list in tabular form
Posted: May 15, 2007 4:40 PM   in response to: VANJ in response to: VANJ
Click to report abuse...   Click to reply to this thread Reply
Vikas,

thanks. my problem is even with firefox, I'm getting only one value passed to the hidden item when I tried to access that item in the page process. In the process of debugging, then I put a alert statement in the javascript to see the value passed to the function after clicking submit button. but in the javascript also, only one value is returned, even though multiple values are selected in LOV. I think I'm mssing something, appreciate your help.

thanks,
Surya
VANJ

Posts: 6,048
Registered: 03/18/04
Re: How to use multiselect list in tabular form
Posted: May 15, 2007 7:18 PM   in response to: sgodavar in response to: sgodavar
Click to report abuse...   Click to reply to this thread Reply
My example now works properly in both IE and FF as you can see yourself. Not sure what you are doing differently. Time for you to do what I did i.e. put up an example on apex.oracle.com so we can see what you are doing. Not sure how else I can help you. Follow my earlier instructions carefully, alert() that l_selected variable in the Javascript function, that is the value that contains all the selected options and that is stored in the hidden item. Basic debugging steps.

Good luck.
sgodavar

Posts: 381
Registered: 01/10/01
Re: How to use multiselect list in tabular form
Posted: May 16, 2007 7:37 AM   in response to: VANJ in response to: VANJ
Click to report abuse...   Click to reply to this thread Reply
Vikas,

I have created a sample page. The first query region contains the "empno" and "lov value". the second region is just a report to display the updated values after submitting the first region. as an example, I'm selecting the following values in LOV for testing

empno lov_value
7369 one
7499 one and two
7521 one, two and three

after selecting the above values in the first region and submitted, I'm picking the hidden value and written into the test_table in the page process. I was expecting the following values in the table in the format below, but all the three rows single value.

7369 one
7499 one:two
7521 one:two:three

http://apex.oracle.com/pls/otn
workspace:surya
username/password - surya_godavarthi@yahoo.com/testapp

page #4 in test application has the query region and the process

http://apex.oracle.com/pls/otn/f?p=17278:4

thanks for your help,
Surya

VANJ

Posts: 6,048
Registered: 03/18/04
Re: How to use multiselect list in tabular form
Posted: May 16, 2007 8:25 AM   in response to: sgodavar in response to: sgodavar
Click to report abuse...   Click to reply to this thread Reply
You were making a very simple mistake.

In your after-submit process, the multiple colon-delimited values are stored in the hidden array (g_f03 in your example, not g_f02).

I also changed the f03 element from a hidden to a simple textbox so you can see how the Javascript combines your selected values as you select/unselect them.

Change the onclick event to a onblur event, that seems to work better in IE (FF is fine either way)

Hope this helps.
sgodavar

Posts: 381
Registered: 01/10/01
Re: How to use multiselect list in tabular form
Posted: May 16, 2007 10:50 AM   in response to: VANJ in response to: VANJ
Click to report abuse...   Click to reply to this thread Reply
Vikas,

thank much. right, I should use g_f03. I was using g_f03 earlier and changed it to g_f02 for testing. Now, I found the main problem is HTMLDB version 2.2 which somehow does not like the javascript , may be missing some js functions?. the same page which is on APEX site with 3.0 does not work in HTMLDB 2.2 on my dev instance, but works fine 3.0 version on my test instance. I think it's something to do with the javascript funcion calls, could you please throw some light on this?

thanks,
Surya
Legend
Guru Guru : 2500 - 1000000 pts
Expert Expert : 1000 - 2499 pts
Pro Pro : 500 - 999 pts
Journeyman Journeyman : 200 - 499 pts
Newbie Newbie : 0 - 199 pts
Oracle ACE Director
Oracle ACE Member
Oracle Employee ACE
Helpful Answer (5 pts)
Correct Answer (10 pts)

Point your RSS reader here for a feed of the latest messages in all forums