Home » SQL & PL/SQL » SQL & PL/SQL » Dynamic lists with multiple selections possible
icon5.gif  Dynamic lists with multiple selections possible [message #196252] Wed, 04 October 2006 11:55 Go to next message
Messages: 9
Registered: July 2006
Junior Member
I am trying to create a web form using PL/SQL and html against an Oracle database. The form displays many options a user can select and then a report is displayed based on those selections.

Does anyone have an example of how to make a series of dynamic lists that allow multiple selections in each list where the second and succeeding lists don't display until after selections are made in the first or preceeding lists?

For example, the first list displays and shows six options and you choose two. Then the second list displays showing selections based on the two you chose in the first list and so on. If you don't chose any selections in the second list the third list never displays.

Any help would be greatly appreciated. Thanks.
Re: Dynamic lists with multiple selections possible [message #196315 is a reply to message #196252] Thu, 05 October 2006 00:15 Go to previous messageGo to next message
Messages: 7880
Registered: March 2000
Senior Member
Sounds more like a JavaScript question to me than PL/SQL.
Guess you will have more luck in a javascript-forum.
Re: Dynamic lists with multiple selections possible [message #196712 is a reply to message #196252] Fri, 06 October 2006 13:09 Go to previous messageGo to next message
Messages: 50
Registered: December 2005
Here's one method. I've just used two lists. The second will show up after the 1st is selected.

create or replace procedure testlist(
  pi_deptno in number default null
 l_base_url  varchar2(250) := 'http://localhost/pls/aportal/testlist';
 l_select    varchar2(10);



    -- javascript function to refresh window 
    htp.p('<script type="text/javascript">');
       htp.p('  function refreshWin()                                                        ');
       htp.p('  {                                                                            ');
       htp.p('   myIndex = document.form1.pi_deptno.selectedIndex;                            ');	  
       htp.p('   var myDept = document.form1.pi_deptno.options[myIndex].value;                ');
       htp.p('   var myUrl ="' || l_base_url || '";                                          ');  
       htp.p('   myUrl = myUrl + "?pi_deptno=" + myDept;                                      ');  
       htp.p('   window.location=myUrl;                                                      ');
       htp.p('  }                                                                            ');  

    htp.p('<form name="form1" action="some_action">');

      -- first select list for unique department names 
      htp.p('<label for="pi_deptno">Department:</label>');
      htp.p('<select name="pi_deptno" onchange="javascript: refreshWin();">');
       htp.p('<option value="">Pick Department</option>');
       for r1 in (select distinct d.dname, d.deptno 
                   from scott.emp e, scott.dept d
                   where e.deptno = d.deptno)
         -- detect which option is selected 
         if pi_deptno = r1.deptno 
          l_select := 'selected';
         end if;
         htp.p('<option value="' || r1.deptno || '" ' || l_select || '>' || r1.dname || '</option>');
       end loop;
      if pi_deptno is not null
        htp.p('<label for="pi_emp">Employee:</label>');
        htp.p('<select name="pi_emp">');
         -- options for second list based on selection of first (if selected) 
         for r1 in (select ename 
                     from scott.emp
                     where deptno = nvl(pi_deptno, deptno) )
           htp.p('<option value="' || r1.ename || '">' || r1.ename || '</option>');
         end loop;
      end if;




end testlist;

You could also include all the lists and then use javascript to enable and disable them once selections are made. I believe this is what Frank has suggested.
Re: Dynamic lists with multiple selections possible [message #196713 is a reply to message #196712] Fri, 06 October 2006 13:37 Go to previous message
andrew again
Messages: 2577
Registered: March 2000
Senior Member
Previous Topic: Table Type list from a schema
Next Topic: Returning Recordset from PL/SQL
Goto Forum:

Current Time: Sun Aug 20 14:22:29 CDT 2017

Total time taken to generate the page: 0.01175 seconds