--- /dev/null
+<html><head><title>Specify route</title></head><body>
+
+<%perl>
+my %a;
+my @vars;
+
+@vars= ({ Name => 'Ocean',
+ Before => 'Ocean: ',
+ CmpCanon => sub { ucfirst lc $_[0] },
+ Values => [ qw(Midnight Ice) ]
+ }, { Name => 'Dropdowns',
+ Before => 'Interface: ',
+ CmpCanon => sub { !!$_[0] },
+ Values => [ [ 0, 'Type in names' ],
+ [ 4, 'Select from menus' ] ]
+ });
+
+foreach my $var (@vars) {
+ my $name= $var->{Name};
+ $var->{Before}= '' unless exists $var->{Before};
+ $var->{CmpCanon}= sub { $_[0]; } unless exists $var->{CmpCanon};
+ foreach my $val (@{ $var->{Values} }) {
+ next if ref $val;
+ $val= [ $val, encode_entities($val) ];
+ }
+ if (exists $ARGS{lc $name}) {
+ $a{$name}= $ARGS{lc $name};
+ } else {
+ $a{$name}= $var->{Values}[0][0];
+ }
+}
+
+foreach my $var (@vars) {
+ my $name= $var->{Name};
+ my $delim= $var->{Before};
+ my $canon= &{$var->{CmpCanon}}($a{$name});
+ my $cvalix= 0;
+ foreach my $valr (@{ $var->{Values} }) {
+ print $delim; $delim= "\n|\n";
+ my ($value,$html) = @$valr;
+ my $iscurrent= &{$var->{CmpCanon}}($value) eq $canon;
+ my $after;
+ if ($iscurrent) {
+ print '<b>';
+ $after= '</b>';
+ } else {
+ my %qf= ();
+ foreach my $innerr (@vars) {
+ my $n= lc $innerr->{Name};
+ if ($n ne lc $name) {
+ next unless exists $ARGS{$n};
+ $qf{$n}= $ARGS{$n};
+ } else {
+ next if !$cvalix;
+ $qf{$n}= $value;
+ }
+ }
+ my $uri= URI->new($self_url);
+ $uri->query_form(%qf);
+ print '<a href="', $uri->path_query(), '">';
+ $after= '</a>';
+ }
+ print $html, $after;
+ $cvalix++;
+ }
+ print '<p>';
+}
+
+db_setocean($a{'ocean'});
+db_connect();
+
+</%perl>
+
+<h1>Specify route</h1>
+<form action="/ucgi/~clareb/mason/something" method="get">
+
+% if (!$a{Dropdowns}) {
+Enter route (islands, or archipelagoes, separated by commas;
+ abbreviations are OK):<br>
+<input type="text" name="routestring" size=80><br>
+<div name="results"></div></br>
+% } else {
+
+<%perl>
+my $sth=$dbh->prepare("SELECT islandid,islandname
+ FROM islands
+ ORDER BY islandname;");
+$sth->execute();
+my $row;
+my $islandlistdata='';
+while ($row=$sth->fetchrow_arrayref) {
+ $islandlistdata.=
+ sprintf('<option value="%s">%s</option>',
+ map { encode_entities($_) } @$row);
+}
+</%perl>
+
+<table>
+<tr>
+% for my $dd (0..$a{Dropdowns}-1) {
+<td><select name="islandid<% $dd %>">
+<option name="none">Select island...</option>
+<% $islandlistdata %></select></td>
+% }
+% }
+</tr>
+</table>
+
+<input type=submit name=submit value="Go">
+</form>
+
+<%init>
+use CommodsWeb;
+use HTML::Entities;
+
+</%init>