I have a very large form that is mailed to several aliases determined by mapping a country name to a region. I have a list of all countries and their respective regions in a text file formatted this way:
... namerica:united states samerica:brazil ...
So North America has an alias, South America has one and so on. In my CGI, I built a pull down from this list from that file and have a sub that maps to the correct regional email alias.
The problem: I need to call the sub that generates the pull down more than once. Here is some sample code to try and reiterate/illustrate what I am trying to accomplish
#the email part of the CGI ... Country: $param{country} ... #sub to create HTML pull down sub generateCountries{ my (@all_countries, $HTML_String); open(FILE, "<countries.txt") or die "cannot read file"; while(<FILE>){ if(/(.*):(.*)/i){ push @all_countries, $1; } } my $HTML_String = "\t" . '<select name = "country"> <option name="country" value="">-- Select a Country --</option +>'; for(my $i = 0; $i < $#all_countries; $i++){ $HTML_String .= "\t\t" . '<option value = "' . $all_countries +[$i] . '">' . $all_countries[$i] . "</option>\n"; } $HTML_String .= "\t</select>"; return $HTML_String; #the HTML form call to CGI that prints pull down <td> Country:</td><td colspan='2'> <?pp:CALL:ALL_COUNTRIES?></td></td>
Any suggestions on how to make this work with out having to write that whole sub over and over again (I need 4 pull downs), so I will end up with something more like this:
Thanks All... Country : $param{country} Country1: $param{country1} Country2: $param{country2} ...
CSUhockey3
In reply to dynamic HTML pull down by csuhockey3
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |