Home > Archive > PHP Pear > March 2007 > Quickform hierselect
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Quickform hierselect
|
|
| Henrik Hansen 2007-03-13, 7:02 pm |
| Hello,
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)
--
Henrik Hansen
| |
| Mark Wiesemann 2007-03-13, 7:02 pm |
| 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
| |
| Henrik Hansen 2007-03-14, 8:02 am |
| Mark Wiesemann <wiesemann@php.net> writes:
> Henrik Hansen wrote:
>
>
> This is the example from the package file (elements.php):
>
>
> This should give you the idea for the third, fourth etc. level.
>
Thanks a lot! It works perfectly.
--
Henrik Hansen
| |
|
|
|
|
|