Re: Quickform hierselect

From: Date: Tue, 13 Mar 2007 21:28:39 +0000
Subject: Re: Quickform hierselect
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-26841@lists.php.net to get a copy of this message
Henrik Hansen wrote: > I currently use hierselect with quickform and works perfectly. But now > I need to add a third dropdown which is filled with options depending > on the selection in the second dropdown. I am pretty sure I saw an example > of this at some point but I can't find it now.. If someone could point > me in the right direction I would be very greatful. (or have a way of > solving it without hierselect) This is the example from the package file (elements.php): $main[0] = "Pop"; $main[1] = "Rock"; $main[2] = "Classical"; $secondary[0][0] = "Belle & Sebastian"; $secondary[0][1] = "Elliot Smith"; $secondary[0][2] = "Beck"; $secondary[1][3] = "Noir Desir"; $secondary[1][4] = "Violent Femmes"; $secondary[2][5] = "Wagner"; $secondary[2][6] = "Mozart"; $secondary[2][7] = "Beethoven"; $opts[] = $main; $opts[] = $secondary; $hs =& $form->addElement('hierselect', 'ihsTest', 'Hierarchical select:', array('style' => 'width: 20em;'), '<br />'); $hs->setOptions($opts); You can now define something like: $third_level[2][7][0] = 'Beethoven A'; $third_level[2][7][1] = 'Beethoven B'; $third_level[2][7][2] = 'Beethoven C'; or $third_level[0][0][0] = "Belle & Sebastian A"; $third_level[0][0][1] = "Belle & Sebastian B"; Of course, you also need this line: $opts[] = $third_level; This should give you the idea for the third, fourth etc. level. Regards, Mark -- http://www.markwiesemann.eu

« previous php.pear.general (#26841) next »