Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

Returning ID as value in dropdown

Quote Reply
Returning ID as value in dropdown
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?

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
Subject Author Views Date
Thread Returning ID as value in dropdown sangiro 2055 Oct 21, 2004, 4:04 AM
Thread Re: [sangiro] Returning ID as value in dropdown
Andy 2025 Oct 21, 2004, 5:24 AM
Thread Re: [Andy] Returning ID as value in dropdown
sangiro 2011 Oct 21, 2004, 8:41 AM
Thread Re: [sangiro] Returning ID as value in dropdown
Andy 2009 Oct 21, 2004, 8:54 AM
Post Re: [Andy] Returning ID as value in dropdown
sangiro 2010 Oct 21, 2004, 9:09 AM