Gossamer Forum
Home : Products : Others : Gossamer Community :

Getting the value

Quote Reply
Getting the value
Hi,

I have a dropdown selection box on the profile page for Country. Form names is a two letter abreviation and the form value is the full name.

If I try to access the setting - I will get the 2 letter abreviation from the Form Names - the questions is - how can I display the Form Value - ie the full name?

It may not be possible as the values are not stored in the database - but is there a way using a global or should I make a ton of if statements in the template?

This is similar to the problem raised in:
http://www.gossamer-threads.com/...orum.cgi?post=231672

Klaus

http://www.ameinfo.com

Last edited by:

klauslovgreen: Feb 7, 2003, 11:04 PM
Quote Reply
Re: [klauslovgreen] Getting the value In reply to
You may use the form_names & form_values table property methods of GT::SQL::table. Check more info about it, in the LSQL GT Module Documentation. That would be a good startpoint.
I took the time and listed some code:
Code:
@form_names = @{$DB->table('comm_users')->form_names->{'Country'}};
@form_values = @{$DB->table('comm_users')->form_values->{'Country'}};

Not sure which one of the following, but one is also needed
(I always confuse names & values Wink):
@form_hash { @form_values } = @form_names;
or
@form_hash { @form_names } = @form_values;
Now you have a %form_hash hash to convert form values.
Use:
Code:
print $form_hash{'us'}; # this will display Unites States of America


Well I did not test this, but theoritically should work...
Play with it, and read the docs.

Hope that helps.

Best regards,
Webmaster33


Paid Support
from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...

Last edited by:

webmaster33: Feb 8, 2003, 9:15 AM
Quote Reply
Re: [klauslovgreen] Getting the value In reply to
If you are only storing the abbreviation then there is no way to show the whole name without some custom coding.

You'd need some sort of mapping for abbreviation to full name, either as a hash or in a flatfile and then use a global to return the value.

eg...

<%load_full_country($country_abbrev)%>

Then in your global if you had a hash of countries/abbrev's you'd do:

Code:
sub {
my $map = {
GB => 'Great Britain',
...
};
return $map->{$_[0]};
}

Last edited by:

Paul: Feb 8, 2003, 9:08 AM
Quote Reply
Re: [Paul] Getting the value In reply to
Thanks Paul

http://www.ameinfo.com