Just change it a litle bit like:
sub {
my ($select_name, $cat_id) = @_;
my $tags = GT::Template->tags;
my $db = $DB->table('Product_Category');
my $results = $db->select({ category_code => $cat_id }, ['product_code', 'product_name'])->fetchall_hashref;
my $html = "<select name='$select_name'><option value=''>----</option>";
foreach (@$results) {
$html .= ($tags->{$select_name} eq $_->{product_code}) ? "<option value='$_->{product_code}' selected>$_->{product_name}</option>" : "<option value='$_->{product_code}'>$_->{product_name}</option>";
}
return $html;
}
It should work.
TheStone.
B.
sub {
my ($select_name, $cat_id) = @_;
my $tags = GT::Template->tags;
my $db = $DB->table('Product_Category');
my $results = $db->select({ category_code => $cat_id }, ['product_code', 'product_name'])->fetchall_hashref;
my $html = "<select name='$select_name'><option value=''>----</option>";
foreach (@$results) {
$html .= ($tags->{$select_name} eq $_->{product_code}) ? "<option value='$_->{product_code}' selected>$_->{product_name}</option>" : "<option value='$_->{product_code}'>$_->{product_name}</option>";
}
return $html;
}
It should work.
TheStone.
B.