1 2 Previous Next 23 Replies Latest reply on May 29, 2011 9:40 PM by fac586

    How to use multiselect list in tabular form

      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,
        • 1. Re: How to use multiselect list in tabular form
          Dimitri Gielis
          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,
          • 2. Re: How to use multiselect list in tabular form
            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
            end loop;
            • 3. Re: How to use multiselect list in tabular form
              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,
              • 4. Re: How to use multiselect list in tabular form
                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!
                • 5. Re: How to use multiselect list in tabular form
                  Hi Surya,

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

                  My APEX Blog: http://inside-apex.blogspot.com
                  The ApexLib Framework: http://apexlib.sourceforge.net
                  The APEX Builder Plugin: http://sourceforge.net/projects/apexplugin/
                  • 6. Re: How to use multiselect list in tabular form
                    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.

                    • 7. Re: How to use multiselect list in tabular form
                      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
                      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.
                      • 8. Re: How to use multiselect list in tabular form

                        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,

                        • 9. Re: How to use multiselect list in tabular form
                          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.
                          • 10. Re: How to use multiselect list in tabular form

                            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.

                            • 11. Re: How to use multiselect list in tabular form
                              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.
                              • 12. Re: How to use multiselect list in tabular form

                                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

                                username/password - surya_godavarthi@yahoo.com/testapp

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


                                thanks for your help,
                                • 13. Re: How to use multiselect list in tabular form
                                  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.
                                  • 14. Re: How to use multiselect list in tabular form

                                    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?

                                    1 2 Previous Next