#################################################################### # M U L T I P L E S E L E C T F I E L D # # "Borrowed" from Links 2.0 # Author: Alex Krohn # # Adapted for use with DBMan by JPDeni # July 7, 2000 #################################################################### # # Replace sub build_select_field with the following. Your regular, # non-multiple select fields will work just the same as they did before. # # There are two features of this version of the subroutine. First, it # will allow you to define the options for several database fields only once. # For example, if you had two select fields that were lists # of states -- BornState and ResidenceState -- you could create just # one select field to apply to both. Call it "State" and use the # following syntax in sub html_record_form: print &build_select_field("BornState",$rec{'BornState'},"State"); # and print &build_select_field("ResidenceState",$rec{'ResidenceState'},"State"); # To use the multiple selection, add the size (height) of your desired multiple select field. # For example, if you wanted to have a multiple select field that was 3 lines tall, you would use print &build_select_field("ResidenceState",$rec{'ResidenceState'},"State",3); # Note that, while the third and fourth parameters are optional, if you # use the size option, you must add a '' to hold the place of the name option: print &build_select_field("ResidenceState",$rec{'ResidenceState'},'',3); # To enter multiple options, users must hold the CTRL key while making # their selections. It would probably be a good idea to give that instruction on your form. ##################################################################### sub build_select_field { # -------------------------------------------------------- # Builds a SELECT field based on information found # in the database definition. # my ($column, $value, $name, $size) = @_; my (%values,@fields,$field); $name || ($name = $column); @fields = split (/\,/, $db_select_fields{$name}); ($#fields >= 0) or return "error building select field: no select fields specified in config for field '$column'!"; if ($size) { %values = map { $_ => 1 } split (/\Q$db_delim\E/, $value); } else { $values{$value}++; } if ($size) { $output = qq|