Heya all,
I use the global below to generate a dropdown of links from a LinsSQL db. The way this is written it returns the Title as the "value" of the dropdown. I would like to display the Title field in the dropdown but actually return the ID of the link as the value.
I want this line:
$output .= "<option selected>$title";
changed to something like:
$output .= "<option selected value=$ID>$title";
Any suggestions on how I should tweak the Global?
my $db = GT::SQL->new('/path/to/other/linksSQL/admin/defs');
my $tbl = $db->table('Links');
my $selected = GT::Template->tags->{event_dz};
$tbl->select_options('ORDER BY Title');
my $sth = $tbl->select(['Title']);
my $output = '<select name="event_dz" size="1"><option></option>';
while (my ($title) = $sth->fetchrow_array) {
$title = $IN->html_escape($title);
if ($title eq $selected) {
$output .= "<option selected>$title";
}
else {
$output .= "<option>$title";
}
}
$output .= "</select>";
return \$output;
}
Safe swoops
Sangiro
I use the global below to generate a dropdown of links from a LinsSQL db. The way this is written it returns the Title as the "value" of the dropdown. I would like to display the Title field in the dropdown but actually return the ID of the link as the value.
I want this line:
$output .= "<option selected>$title";
changed to something like:
$output .= "<option selected value=$ID>$title";
Any suggestions on how I should tweak the Global?
Code:
sub { my $db = GT::SQL->new('/path/to/other/linksSQL/admin/defs');
my $tbl = $db->table('Links');
my $selected = GT::Template->tags->{event_dz};
$tbl->select_options('ORDER BY Title');
my $sth = $tbl->select(['Title']);
my $output = '<select name="event_dz" size="1"><option></option>';
while (my ($title) = $sth->fetchrow_array) {
$title = $IN->html_escape($title);
if ($title eq $selected) {
$output .= "<option selected>$title";
}
else {
$output .= "<option>$title";
}
}
$output .= "</select>";
return \$output;
}
Safe swoops
Sangiro