i'm trying to customize my html_record_form for a particular database and think maybe it's a complicated perl issue. see my post in the perl forum for details. if you have any suggestions, please let me know.
Mar 24, 2009, 3:28 PM
Enthusiast (661 posts)
Mar 24, 2009, 3:28 PM
Post #2 of 3
Views: 3688
i've been doing more research and it seems like i should be able to use :
<INPUT TYPE="CHECKBOX" NAME="Preference" VALUE="Pre-planning" CHECKED><INPUT TYPE="CHECKBOX" NAME="Preference" VALUE="Setup"><INPUT TYPE="CHECKBOX" NAME="Preference" VALUE="Removal" CHECKED>
in my form, i.e. use the same fieldname Preference for all the checkboxes. shouldn't sub parse_form gather all the checked items and put the ~~ between them automatically?
sub parse_form {my (%in);
my ($buffer, $pair, $name, $value);
PAIR: foreach $name ($query->param()) {
@value = $query->param("$name");
$value = join '~~', @value;
$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;
if ($value eq "---") { next PAIR; }
if ($value eq "http://") { next PAIR; } # Removes default beginning of URLs
unless ($value) { next PAIR; }
$in{$name} = $value;
}
return %in;
}
i am able to read the existing record correctly for each value to determine whether CHECKED should be in the input line.
however when i make any change to the record, it says Preference is blank (required field error). but on the form it still shows the checkmarks properly. i don't understand why it's wiping out the value of Preference.
Code:
<INPUT TYPE="CHECKBOX" NAME="Preference" VALUE="Pre-planning" CHECKED><INPUT TYPE="CHECKBOX" NAME="Preference" VALUE="Setup"><INPUT TYPE="CHECKBOX" NAME="Preference" VALUE="Removal" CHECKED>
in my form, i.e. use the same fieldname Preference for all the checkboxes. shouldn't sub parse_form gather all the checked items and put the ~~ between them automatically?
Code:
sub parse_form {my (%in);
my ($buffer, $pair, $name, $value);
PAIR: foreach $name ($query->param()) {
@value = $query->param("$name");
$value = join '~~', @value;
$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;
if ($value eq "---") { next PAIR; }
if ($value eq "http://") { next PAIR; } # Removes default beginning of URLs
unless ($value) { next PAIR; }
$in{$name} = $value;
}
return %in;
}
i am able to read the existing record correctly for each value to determine whether CHECKED should be in the input line.
however when i make any change to the record, it says Preference is blank (required field error). but on the form it still shows the checkmarks properly. i don't understand why it's wiping out the value of Preference.