Home : Products : DBMan : Customization :

Products: DBMan: Customization: Re: [JPWiese] Multiple Select?: Edit Log

Here is the list of edits for this post
Re: [JPWiese] Multiple Select?
This is the version I have the most success with:

sub build_multiple_select_field {
# --------------------------------------------------------
# Builds a SELECT field based on information found in the database definition. Parameters are the column to build, a default value, a default name, whether to allow multiple selections, and the size of the box.

my ($column, $value, $size) = @_;
my (@fields, @values, $output);

$size or ($size = 1);

if ($mult) { @values = split (/\Q$db_delim\E/,$value); }
else { @values = ($value); }
@fields = split (/\,/, $db_select_fields{$column});
if (! exists ($db_select_fields{$column})) {
$output = "error building select field: no fields specified/unkown field ($column)!";
}
else {
$output = qq|<SELECT NAME="$column" MULTIPLE SIZE=$size><OPTION>---|;
foreach $field (sort @fields) {
if (grep $_ eq $field, @values) {
$output .= "<OPTION SELECTED>$field\n";
}
else {
$output .= "<OPTION>$field";
}
}
$output .= "</SELECT>";
}
return $output;
}

Then in your html.pl file within sub html_record_form when you define your multiple select field use:

|; print &build_multiple_select_field("Country",$rec{'Country'},3); print qq|


In your .cfg file be sure you have the select field defined as a select

'Country' => [ 5,'alpha',0,50,1,'',''], # multiple select


%db_select_fields = (
'Country' => 'Afghanistan,Albania,Algeria,American Samoa,Andorra,Angola,Anguilla,Antarctica'
);

Adding all your country selections above. Be sure you don't have any spaces between the country names.

Hope this helps, if not, perhaps if you make a .txt copy of your files and post the url to where they can be viewed we can help you get this working.

Please state exactly what is not working.

P.S. It might help to include a note to your users to hold down the CTRL key while making multiple selections.

Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/

Last edited by:

LoisC: Apr 28, 2002, 11:14 AM

Edit Log: