Andy:
You're right! I added some comments before the 'sub'.
I also note that your global above pulls out 'all' values from the table, even though those that aren't listed in the Admin Panel. This global will only select those that have been entered into Admin and will also sort them. I found this elsewhere in the Forum - it is not my work...
my $column = shift;
my $selected = shift;
my $table = $DB->table("Links");
my %hash;
my $i = 0;
my $names = $table->form_names->{$column};
my $vals = sort $table->form_values->{$column};
for my $val (@$vals) {
$hash{$val} = $names->[$i++];
}
my $html = $DB->html($table, $IN);
my $form = $html->select({
name => "$column",
values => \%hash,
value => $selected });
return $form;
}
To call:
<%global_name('ColumnName',$ColumnName)%>
Thanks,
Clint.
--------------------------
http://AffiliatesDirectory.com
The Affiliate Programs Directory
You're right! I added some comments before the 'sub'.
I also note that your global above pulls out 'all' values from the table, even though those that aren't listed in the Admin Panel. This global will only select those that have been entered into Admin and will also sort them. I found this elsewhere in the Forum - it is not my work...
Code:
sub { my $column = shift;
my $selected = shift;
my $table = $DB->table("Links");
my %hash;
my $i = 0;
my $names = $table->form_names->{$column};
my $vals = sort $table->form_values->{$column};
for my $val (@$vals) {
$hash{$val} = $names->[$i++];
}
my $html = $DB->html($table, $IN);
my $form = $html->select({
name => "$column",
values => \%hash,
value => $selected });
return $form;
}
To call:
<%global_name('ColumnName',$ColumnName)%>
Thanks,
Clint.
--------------------------
http://AffiliatesDirectory.com
The Affiliate Programs Directory