Hello friends, can someone explain to me how can I submit form with radio button ?

I know how to fill and submit form if the form contain just a textboxes, here is the code:

#!c:\\perl\\bin

use strict;
use WWW::Mechanize;
use HTTP::Cookies;

my $outfile		= "out.htm";
my $url 		= "";
my $username 	= "";
my $password 	= "";
my $useragent	= "Mozilla/9.876 (X11; U; Linux 2.2.12-20 i686, en; rv:2.0) Gecko/25250101 Netscape/5.432b1 (C-MindSpring)";

my $mech = WWW::Mechanize->new( agent => $useragent);
$mech->cookie_jar(HTTP::Cookies->new());
$mech->get($url);

#$mech->form_name('form_name');
#$mech->field(myusername => $username);
#$mech->field(mypassword => $password);
#$mech->click();
#or...

$mech->submit_form(
        form_number => 1,
        fields      => { login => $username, pass => $password },
    );

my $output_page = $mech->content();
open(OUTFILE, ">$outfile");
print OUTFILE "$output_page";
close(OUTFILE);

But I don't know how to select one of several radio buttons...

If someone wants to help me I would be grateful.

Thanks.

The problem is solved, here is the sollution:

#...

# work = radio button name
# 1 = value of the radio button who want to select
$mech->submit_form(
        form_number => 1,
        fields      => { work => 1 },
    );

#...
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.