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

Dynamically generate a drop-down field for a field...

Quote Reply
Dynamically generate a drop-down field for a field...
Just thought I would post this... as it seems to work a treat for me =)

Code:
sub {

my $field = $_[0];

my $table = $DB->table('Links');
my $sth = $table->select( ["DISTINCT($field)"] );

my $back = qq|<select name="$field">|;

while (my ($name) = $sth->fetchrow_array) {
$back .= qq|<option>$name</option>|;
}

$back .= '</select>';
return $back;
}

Code:
<%global_name('FieldName')%>

For example,

Code:
<%select_GEN('Country')%>

.. which would then generate a select box called "Country".

Enjoy Smile

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Subject Author Views Date
Thread Dynamically generate a drop-down field for a field... Andy 14079 Aug 28, 2004, 12:49 AM
Thread Re: [Andy] Dynamically generate a drop-down field for a field...
sangiro 13591 Aug 28, 2004, 1:49 AM
Thread Re: [sangiro] Dynamically generate a drop-down field for a field...
Andy 13651 Aug 28, 2004, 1:55 AM
Post Re: [Andy] Dynamically generate a drop-down field for a field...
ajiimd 13472 Sep 4, 2004, 4:30 PM
Post Re: [Andy] Dynamically generate a drop-down field for a field...
ajiimd 13558 Sep 5, 2004, 5:29 AM
Thread Re: [Andy] Dynamically generate a drop-down field for a field...
mick31 13416 Apr 22, 2005, 1:08 PM
Post Re: [mick31] Dynamically generate a drop-down field for a field...
Andy 13385 Apr 23, 2005, 2:16 AM
Thread Re: [Andy] Dynamically generate a drop-down field for a field...
Clint 13362 Apr 24, 2005, 2:20 AM
Thread Re: [Clint] Dynamically generate a drop-down field for a field...
Andy 13438 Apr 24, 2005, 11:49 AM
Thread Re: [Andy] Dynamically generate a drop-down field for a field...
Clint 13568 Apr 24, 2005, 5:19 PM
Thread Re: [Clint] Dynamically generate a drop-down field for a field...
kailew 13317 Dec 17, 2005, 2:16 AM
Thread Re: [kailew] Dynamically generate a drop-down field for a field...
Clint 13258 Dec 17, 2005, 2:29 AM
Thread Re: [Clint] Dynamically generate a drop-down field for a field...
kailew 13178 Dec 17, 2005, 2:45 AM
Thread Re: [kailew] Dynamically generate a drop-down field for a field...
Clint 13217 Dec 17, 2005, 4:46 PM
Thread Re: [Clint] Dynamically generate a drop-down field for a field...
kailew 13182 Dec 17, 2005, 4:53 PM
Thread Re: [kailew] Dynamically generate a drop-down field for a field...
Andy 13236 Dec 18, 2005, 11:44 PM
Thread Re: [Andy] Dynamically generate a drop-down field for a field...
kailew 13230 Dec 19, 2005, 12:41 AM
Thread Re: [kailew] Dynamically generate a drop-down field for a field...
Andy 13256 Dec 19, 2005, 2:28 AM
Thread Re: [Andy] Dynamically generate a drop-down field for a field...
kailew 13279 Dec 19, 2005, 3:00 AM
Thread Re: [kailew] Dynamically generate a drop-down field for a field...
Andy 13212 Dec 19, 2005, 3:08 AM
Thread Re: [Andy] Dynamically generate a drop-down field for a field...
kailew 13224 Dec 19, 2005, 3:13 AM
Thread Re: [kailew] Dynamically generate a drop-down field for a field...
Andy 13248 Dec 19, 2005, 3:16 AM
Thread Re: [Andy] Dynamically generate a drop-down field for a field...
kailew 13212 Dec 19, 2005, 3:22 AM
Thread Re: [kailew] Dynamically generate a drop-down field for a field...
Andy 13201 Dec 19, 2005, 3:28 AM
Thread Re: [Andy] Dynamically generate a drop-down field for a field...
kailew 13118 Dec 19, 2005, 4:02 AM
Thread Re: [kailew] Dynamically generate a drop-down field for a field...
Andy 6248 Dec 19, 2005, 4:03 AM
Thread Re: [Andy] Dynamically generate a drop-down field for a field...
kailew 6194 Dec 22, 2005, 12:22 AM
Thread Re: [kailew] Dynamically generate a drop-down field for a field...
Andy 6252 Dec 22, 2005, 1:18 AM
Post Re: [Andy] Dynamically generate a drop-down field for a field...
kailew 6166 Dec 22, 2005, 2:05 AM
Thread Post deleted by kailew
kailew 6228 Dec 22, 2005, 2:42 AM
Post Re: [kailew] Dynamically generate a drop-down field for a field...
Andy 6199 Dec 22, 2005, 2:56 AM
Thread Re: [Andy] Dynamically generate a drop-down field for a field...
Mark2 6077 Apr 19, 2007, 3:32 PM
Thread Re: [Mark2] Dynamically generate a drop-down field for a field...
Andy 6113 Apr 20, 2007, 12:59 AM
Thread Re: [Andy] Dynamically generate a drop-down field for a field...
Mark2 6106 Apr 20, 2007, 7:00 AM
Post Re: [Mark2] Dynamically generate a drop-down field for a field...
Andy 6116 Apr 20, 2007, 7:07 AM
Thread Re: [Andy] Dynamically generate a drop-down field for a field...
MJ_ 5925 Jul 25, 2009, 6:34 AM
Thread Re: [MJ_] Dynamically generate a drop-down field for a field...
Andy 5965 Jul 26, 2009, 12:34 PM
Post Re: [Andy] Dynamically generate a drop-down field for a field...
MJ_ 5918 Jul 27, 2009, 4:50 AM