Gossamer Forum
Home : Products : DBMan : Customization :

special sort and multi select

Quote Reply
special sort and multi select
i'm pulling my hair out!!!! i have a field that has a sort order built into the value:

01:president,02:vice president, 03:secretary ....etc

i'm using it in a checkbox environment and it is possible to select more than one checkbox. believe me i have a good reason for this!

anyway, i can't figure out how to build the checkbox field to strip off the 01: 02: etc so the user only sees the text, not the number.

i'm making a special build checkbox sub by modifying the regular checkbox; see my comments below

sub build_checkbox_spec_field {
# --------------------------------------------------------
# Builds a CHECKBOX field based on information found
# in the database definition. Parameters are the column to build
# whether it should be checked or not and a default value (optional).
my ($column, $values) = @_;
if (!$db_checkbox_fields{$column}) {
return "error building checkboxes: no checkboxes specified in config for field '$column'";
}

my @names = split (/,/, $db_checkbox_fields{$column});
my @values = split (/\Q$db_delim\E/, $values);
my ($name, $output);
foreach $name (@names) {
# i think this is where i need to split the name
# my ($junk,$op_text) = split(/:/, $name);
# then i want to use $op_text instead of $name at end of the lines below, but leave value=$name
# but when i do this, $output is blank
# i think it's because $_ in grep is now wrong but i can't figure out how to restate this
# i want to compare $name to the list in @values; if it's in the list then CHECKED
(grep $_ eq $name, @values) ?
($output .= qq!<INPUT TYPE="CHECKBOX" NAME="$column" VALUE="$name" CHECKED> $name<br>\n!) :
($output .= qq!<INPUT TYPE="CHECKBOX" NAME="$column" VALUE="$name"> $name<br>\n!);
}
return $output;
}

help anyone!!!???