Hi.
Radio buttons are designed so you can only select one of them at a time ( unlike checkboxes ). If you write some code like this:
#!/usr/bin/perl -wT
print "Content-type: text/html\n\n";
use strict;
use CGI;
use CGI::Carp qw( fatalsToBrowser );
my $name;
my $favorite_food;
my $q = new CGI;
$name = $q->param("name");
$favorite_food = $q->param("favorite_food");
print <<EOF;
<HTML>
<HEAD>
<TITLE>
</TITLE>
</HEAD>
<BODY>
<H4>Thank you $name. I also like $favorite_food.</H4>
</BODY>
</HTML>
EOF
If name and favorite_food were designated as fields originating from radio buttons, their 'name/value' would be stored in the respective variables.
Hope this helps,
-DK
| [reply] [d/l] |
As DigitalKitty says, you can only select one radio button at a time. Therefore, by implication, you are always dealing with groups of buttons. Here is a CGI.pm example, which generates the calling form from perl:
#!/usr/local/bin/perl
use strict;
use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrowser);
print header, start_html, h1("Radio Button Test"), "\n";
print start_form(-method=>'GET'),radio_group(
-name => 'test',
-values => ['A','B','C'],
-linebreak => 'true');
print submit(
-name => 'action',
-value => 'go'), end_form, end_html, "\n";
I have used METHOD=GET, so that people running this can see the query string - hence what is being passed in.
Each button has a distinct value, but share a common name. | [reply] [d/l] |