Gossamer Forum
Home : General : Perl Programming :

Passing variable to a radio button variable

Quote Reply
Passing variable to a radio button variable
 
How can I pass a variable to the radio button?

print $query->radio_group(-name=>"$dir",
-default=>'',
-linebreak=>'',
-labels=>\%labels);

This passes the variable but also markes the first button as checked.

print $query->radio_group(-name=>'$dir',
-default=>'',
-linebreak=>'',
-labels=>\%labels);

This leaves the radio button unchecked, but changes the variable to the characters $dir.

I would appreciate any advice you can give me.

Thanks!
Bob Seymour
seymour10@llnl.gov
Quote Reply
Re: [seymour1o] Passing variable to a radio button variable In reply to
Hi Bob,

What is $dir contained? Is it a name or a value?
If it is a name, the -default option should be some value. Ex, -default => "v1" or something like that

If it is a value, it should be passed as default option(e.g. -default => "$dir")

Just let me know if I were misleading.

Cheers.

Cheers,

Cheers,

Dat

Programming and creating plugins and templates
Blog
Quote Reply
Re: [tandat] Passing variable to a radio button variable In reply to
Dat:

I did not want a particular default (Mac/PC or Unix). I wanted the default to be blank buttons.
So the work around I used was making the default be neither of these and used a "-" instead.

-default=>'-'.

For some odd reason it worked. Do you have any better ideas?

Thanks for the reply.

Bob

Quote Reply
Re: [seymour1o] Passing variable to a radio button variable In reply to
So, what do you want to pass to?

Cheers,

Dat

Programming and creating plugins and templates
Blog
Quote Reply
Re: [tandat] Passing variable to a radio button variable In reply to
Here is what I settled on...
for ($i=1; $i < 4; $i++) {
print "<tr><td>$myDir</td>";
print "<td>";
print $query->textfield(-name=>"$dir $i");
print "</td><td>\n";
print $query->radio_group(-name=>"$dir os $i",
-values=>['Mac/PC','Unix'],
-default=>'-');
print "</td></tr>\n";


Somehow it worked..... Tongue