NAME
Javascript::Select::Chain - generate arbitrary depth DHTML select pulldowns
ABSTRACT
This Perl package makes it easy to generate a series of pulldowns whose content is a function of the selection in the previous pulldown. It is a Perl API to a Javascript package written by Xin Yang. His Javascript package is included, but you can consult his website for information beyond this documentation:
http://www.yxscripts.com/
DESCRIPTION
It would really help to read over the docs at:
http://www.yxscripts.com/cs/chainedselects.html
If you read this, then you will have the concepts and vocabulary necessary to understand and use this Perl wrapper to his library.
However, I will do my best to explain everything you need to know here.
selectchain( $model , $options )
selectchain()
takes two arguments. $model
is a hash reference with two keys, data
and listgroupname
. The value of the key listgroupname
is exactly what is referred to in the original docs. See Car1.pm
in the distribution for a sample usage. The value of the key data
is an array reference in which each element completely represents one pulldown in the chain. Summarily, here is $model
at the highest level:
{
data => [ $level1, $level2, $level3 ],
listgroupname => $listgroupname # e.g., 'vehicles'
}
Now, we go into how $level1
, $level2
, ... $levelN
looks. In words, each level is an array reference in which each element is an array reference. The "inner" array reference looks like this:
[ $list_name, $option_text, $option_value => $next_list_name ]
There is also a final optional argument which indicates that this item in the pulldown is the default selected one.
Here is a sample level, completely described:
my $level1 =
[
[ "car-makers", "Select a maker", "", "dummy-list" ],
[ "car-makers", "Toyota", "Toyota", "Toyota" ],
[ "car-makers", "Honda", "Honda", "Honda" ],
[ "car-makers", "Chrysler", "Chrysler", "Chrysler", 1 ],
[ "car-makers", "Dodge", "Dodge", "Dodge" ],
[ "car-makers", "Ford", "Ford", "Ford" ]
];
Car1.pm
in the distro contains a complete example which generates the 3-level hierarchy shown at www.xyscripts.com.
EXPORT
None by default, selectchain
can be exported on request.
SEE ALSO
http://www.yxscripts.com
AUTHOR
Terrence Brannon, <tbone@cpan.org<gt>
COPYRIGHT AND LICENSE
Copyright (C) 2004 by Terrence Brannon
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.5 or, at your option, any later version of Perl 5 you may have available.