Gossamer Forum
Home : Products : DBMan : Customization :

How to print out a particular letter in a field?

Quote Reply
How to print out a particular letter in a field?
Let's say My user can choose "Male" or "Female" in their input. But I just want to print out "M" or "F" instead of the whole word.

Sorry bugging all the helper here.
Quote Reply
Re: How to print out a particular letter in a field? In reply to
There are several ways to do this.

Probably the easiest way would be to add a couple of lines to your default.cfg file:

$gender{'Male'} = "M";
$gender{'Female'} = "F";

You really can put the lines anywhere you want to in the script. I'd probably put them somewhere around where the radio fields are defined.

Then, in html_record, where you want to print out the gender, use

$gender{$rec{'Gender'}}

Change the Gender above to the actual field name you're using for the field.

There are other ways to do it, too -- using "if" statements or just printing out the first letter, but that requires a little more understanding of Perl.

------------------
JPD