p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Classic ASP Basics (http://p2p.wrox.com/forumdisplay.php?f=61)
-   -   Dynamic Dependent List Box improvement (http://p2p.wrox.com/showthread.php?t=16900)

SoC August 15th, 2004 11:54 PM

Dynamic Dependent List Box improvement
 
Hi,

(Please redirect me if this is not the appropriate forum).

Found a tutorial on the Macromedia website for
creating dynamic dependent list/combo boxes:

http://www.macromedia.com/support/dr...ic_listbox.htm

I would like to use it to search a database, however it seems to have one limitation.

I would be using it in the form of 3 combo boxes, i.e., grandparent, parent, child.

I need to be able to add static options to the combo boxes, but I'm not sure how to do this (or whether it is actually possible).

In other words, when someone selects an option from the grandparent box, it automatically loads all the relevant parent options from ny database. I would like to be able to make one of the parent options simply 'all', so that the user has the option of searching on all the parent options rather that being forced to search on one only. And then the same for the child box.

Can anyone point me in the right direction?

Thanks

SoC



SoC August 16th, 2004 01:02 AM

Worked out how to do it.

Just need to add one line of code (bolded) to one of the functions:

Code:

function populateDynaList(oList, nIndex, aArray)

{

  oList.options[oList.options.length] = new Option("All","");

 for (var i = 0; i < aArray.length; i= i + 3){
 
 

  if (aArray[i] == nIndex){
   oList.options[oList.options.length] = new Option(aArray[i + 1], aArray[i + 2]);
  }
 }

 if (oList.options.length == 0){
  oList.options[oList.options.length] = new Option("[none available]",0);
 }
 
 oList.selectedIndex = 0;
}

SoC



All times are GMT -4. The time now is 06:32 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.