use strict; use warnings; my %categories = ( A => [ 'B', 'Z' ], C => ['D', 'E'] ); my $category = param('category') || ''; my $subcategory = param('subcategory') || ''; use CGI qw/:standard/;; # Generate javascript print < function catChange(newCat) { with(document.your_form.subcategory) { options.length=0; switch(newCat) { EOF foreach my $c (keys %categories) { print < EOF # Well, now wasn't that fun?! # Beginning of form print start_form(-name=>'your_form'); print p(popup_menu(-name=>'category', -values=>['Category',sort keys %categories], -onChange=> 'catChange(this.options[this.selectedIndex].value);'), popup_menu(-name=>'subcategory', -values=>['Please choose a category'])); #### printf 'options[%d]=new Option("%s" %s );\n', $i, $s, $opts_params;