CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
Using number in database

 



JFrost
Novice

Oct 4, 2001, 9:45 AM

Post #1 of 2 (284 views)
Using number in database Can't Post

Here is my question.

I am building my fields for my database using the CGI.pm method.

@maritalstatus = ("Never Married", "Divorced", "Widowed", "Separated");

$query = new CGI;

print $query->radio_group(-name=>$maritalstatus,

-values=>\@$maritalstatus,
-labels=>\%labels,
-columns=>3);

This gives me radio buttons with all the values and lables using the fields of maritalstatus. I want to have the label as the field name and the value as the field number. E.g.

@maritalstatus = ("Never Married", "Separated");

<input type=radio name=maritalstatus value=1>Never Married
<input type=radio name=maritalstatus value=2>Separated

How can I do this?

Thanks



Jasmine
Administrator

Oct 4, 2001, 6:36 PM

Post #2 of 2 (274 views)
Re: Using number in database [In reply to] Can't Post

Looks like your code has %labels in it, but %labels isn't being defined anywhere.

Try this:


Code
my %labels = ( 
1 =>"Never Married" ,
2 =>"Divorced" ,
3 =>"Widowed" ,
4 =>"Separated" ,
);

my $query = CGI->new();

print $query->radio_group(
-name => 'maritalstatus',
-values => \%labels,
-labels => \%labels,
-columns => 3,

);


 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives