I'm having a problem that seems to be common, but I can't find a suitable solution after looking thru past posts, unless I simply missed it.
Since adding the upload mod, on my checkbox field, only the first selection is being added with the record and all others in the field are ignored. I've deleted the line:
unless ($value) { next PAIR; }
in the parse_form sub as suggested on another post, but it doesn't solve the problem.
The parse_form code looks like this:
my (%in);
my ($buffer, $pair, $name, $value);
PAIR: foreach $name ($query->param()) {
$value = $query->param("$name");
$name =~ tr/+/ /;
$name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ s/<!--(.|\n)*-->//g;
if ($value eq "---") { next PAIR; }
(exists $in{$name}) ?
($in{$name} .= "~~$value") :
($in{$name} = $value);
}
return %in;
}
My cfg code:
Amenities => [14, 'alpha', 0, 255, 0, '', ''],
and
%db_checkbox_fields = ( Amenities => 'Fireplace,Deck,Pool,Patio,Fenced Yard,1 Car Garage,2 Car Garage,Carport,Refrigerator,Microwave,Range/Oven,Dishwasher,Insulated Windows,Hardwood Floors,Ceramic Tiles,Ceiling Fans,Termite Bond,Basement,Attic,Stor. Bldg.',
Photo => 'Yes'
);
In db.cgi build_checkbox_field:
my @names = split (/,/, $db_checkbox_fields{$column});
my @values = split (/\Q$db_delim\E/, $values);
my ($name, $output);
foreach $name (@names) {
(grep $_ eq $name, @values) ?
($output .= qq!<INPUT TYPE="CHECKBOX" NAME="$column" VALUE="$name" CHECKED> $name\n!) :
($output .= qq!<INPUT TYPE="CHECKBOX" NAME="$column" VALUE="$name"> $name\n!);
}
return $output;
In build-html-record_form (I didn't change any of this from the original DBMAN code):
elsif ($db_checkbox_fields{$field}) { $output .= "<tr><td align=right valign=top width=20%><$font>$field:</font></td><td width=80%>" . &build_checkbox_field ($field, $rec{$field}) . "</td></tr>"; }
Then, in html_record_form:
<TR><TD ALIGN="Right" VALIGN="TOP"><$font>Other Amenities:</FONT></TD>
<TD VALIGN="TOP"> <font face="Verdana, Arial, Helvetica" Size=1 Color=#000000> |; print &build_checkbox_field ("Amenities", "$rec{'Amenities'}"); print qq|</TD></TR>
and in html_record:
<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color>Other Amenities:</FONT></TD>
<TD> <$font>$rec{'Amenities'}</Font></TD></TR>
The Amenities showed up fine (Fireplace|Carport|Basement, etc.) before I installed the upload mod, when I had only the one checkbox field.
Now, since I've added the "Photo" field necessary for the uploading process, it adds only the first Amenity that's checked, whether I upload a photo or not.
What am I missing? Please explain in simple terms, since I'm not well-versed in all this.
Since adding the upload mod, on my checkbox field, only the first selection is being added with the record and all others in the field are ignored. I've deleted the line:
unless ($value) { next PAIR; }
in the parse_form sub as suggested on another post, but it doesn't solve the problem.
The parse_form code looks like this:
my (%in);
my ($buffer, $pair, $name, $value);
PAIR: foreach $name ($query->param()) {
$value = $query->param("$name");
$name =~ tr/+/ /;
$name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ s/<!--(.|\n)*-->//g;
if ($value eq "---") { next PAIR; }
(exists $in{$name}) ?
($in{$name} .= "~~$value") :
($in{$name} = $value);
}
return %in;
}
My cfg code:
Amenities => [14, 'alpha', 0, 255, 0, '', ''],
and
%db_checkbox_fields = ( Amenities => 'Fireplace,Deck,Pool,Patio,Fenced Yard,1 Car Garage,2 Car Garage,Carport,Refrigerator,Microwave,Range/Oven,Dishwasher,Insulated Windows,Hardwood Floors,Ceramic Tiles,Ceiling Fans,Termite Bond,Basement,Attic,Stor. Bldg.',
Photo => 'Yes'
);
In db.cgi build_checkbox_field:
my @names = split (/,/, $db_checkbox_fields{$column});
my @values = split (/\Q$db_delim\E/, $values);
my ($name, $output);
foreach $name (@names) {
(grep $_ eq $name, @values) ?
($output .= qq!<INPUT TYPE="CHECKBOX" NAME="$column" VALUE="$name" CHECKED> $name\n!) :
($output .= qq!<INPUT TYPE="CHECKBOX" NAME="$column" VALUE="$name"> $name\n!);
}
return $output;
In build-html-record_form (I didn't change any of this from the original DBMAN code):
elsif ($db_checkbox_fields{$field}) { $output .= "<tr><td align=right valign=top width=20%><$font>$field:</font></td><td width=80%>" . &build_checkbox_field ($field, $rec{$field}) . "</td></tr>"; }
Then, in html_record_form:
<TR><TD ALIGN="Right" VALIGN="TOP"><$font>Other Amenities:</FONT></TD>
<TD VALIGN="TOP"> <font face="Verdana, Arial, Helvetica" Size=1 Color=#000000> |; print &build_checkbox_field ("Amenities", "$rec{'Amenities'}"); print qq|</TD></TR>
and in html_record:
<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color>Other Amenities:</FONT></TD>
<TD> <$font>$rec{'Amenities'}</Font></TD></TR>
The Amenities showed up fine (Fireplace|Carport|Basement, etc.) before I installed the upload mod, when I had only the one checkbox field.
Now, since I've added the "Photo" field necessary for the uploading process, it adds only the first Amenity that's checked, whether I upload a photo or not.
What am I missing? Please explain in simple terms, since I'm not well-versed in all this.