in reply to dynamic HTML pull down
But a much better solution for your problem in general would be to just use the CGI modules's existing capabilities, including the (horribly-named) popup_menu routine which generates a dropdown. You are using CGI, right?my @countries = do { my $fh; open($fh => "countries.txt") ? map { /(.*):(.*)/ ? $1 : () } <$fh> : (); }; my $dropdown = make_dropdown("dropdown", @countries); my $another = make_dropdown("another", @countries); sub make_dropdown { my ($form_name, @countries) = @_; ## generate and return a dropdown with <select name="$form_name"> }
The benefit of this is that you can easily set the selected value of the dropdown.. And it's already been written and tested, etc.use CGI 'popup_menu'; my $dropdown = popup_menu("dropdown", \@countries); my $another = popup_menu("another", \@countries, "USA"); ## set a de +fault
blokhead
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: dynamic HTML pull down
by csuhockey3 (Curate) on Nov 05, 2003 at 03:29 UTC |