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
anngold
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
Frank
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
rigatonip
Messages: 50
Registered: December 2005
Member
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
)
as
 l_base_url  varchar2(250) := 'http://localhost/pls/aportal/testlist';
 l_select    varchar2(10);
begin

  htp.p('<html>');

   htp.p('<body>');

    -- 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('</script>');

    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)
       loop
  
         -- detect which option is selected 
         if pi_deptno = r1.deptno 
         then 
          l_select := 'selected';
         end if;
  
         htp.p('<option value="' || r1.deptno || '" ' || l_select || '>' || r1.dname || '</option>');
  
       end loop;
  
      htp.p('</select>');
      htp.p('<br>');
  
      if pi_deptno is not null
      then
  
        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) )
         loop 
           htp.p('<option value="' || r1.ename || '">' || r1.ename || '</option>');
         end loop;
    
        htp.p('</select>');
  
      end if;

    htp.p('</form>');

   htp.p('</body>');

  htp.p('</html>');

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
http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:234614318676
Previous Topic: How to make my Form Module online or how to run on machine without form developer
Next Topic: how can i create table
Goto Forum:
  


Current Time: Fri Dec 09 09:55:00 CST 2016

Total time taken to generate the page: 0.08683 seconds