in reply to Drop-down list Option Value
Where do you want *them* to go today?#!/perl/bin/perl use strict; use warnings; use Data::Dumper; # Fish configurator my %fish = ( "Fresh water fish" => "fish1.jpg", "Salt water fish" => "fish2.jpg", "One fish" => "seuss1.jpg", "Two fish" => "seuss2.jpg", "Thanks for all the fish" => "adams.jpg", ); print qq(<form> <select name="fish"> ); # Print each fish's <option> line for my $pet (sort keys %fish) { # Note that $pet is the hash key # ... and $fish{$pet} refers to the value print sprintf qq(<option value="%s">%s</option>\n), $fish{$pet}, $pet; } print qq(</select> </form>); __OUTPUT__ <form> <select name="fish"> <option value="fish1.jpg">Fresh water fish</option> <option value="seuss1.jpg">One fish</option> <option value="fish2.jpg">Salt water fish</option> <option value="adams.jpg">Thanks for all the fish</option> <option value="seuss2.jpg">Two fish</option> </select> </form>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(jeffa) 2Re: Drop-down list Option Value
by jeffa (Bishop) on Feb 02, 2003 at 09:01 UTC | |
by Coruscate (Sexton) on Feb 03, 2003 at 05:03 UTC |