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

Getting an array of passed in values and looping

Quote Reply
Getting an array of passed in values and looping
Hi

I've got a series of checkboxes on a form and am passing in multiple values for that field (called "id"). What I need to know is how to acces those values.

What I'd like to do is get the passed in array and loop through it.

Can anyone tell me how to get hold of that array?

Thanks!
Quote Reply
Re: [ryel01] Getting an array of passed in values and looping In reply to
Hi,

They are stored in the tag, seperated by \n I believe.

Something like this should do it;

Code:
sub {
my @cut = split /\n/, $_[0]
my @tmp;
foreach (@cut) {
chomp;
my $tmp_hash;
$tmp_hash->{val} = $_;
push @tmp, $tmp_hash;
}
return { val_loop => \@tmp };
}

..then call with;

Code:
<%global_name($FieldToRunThroughIt)%>
<%if val_loop%>
<%loop val_loop%>
<%val%><br/>
<%endloop%>
<%endif%>

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!