Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hello,
I know how to use checkbox and buttons. But choosing a radio button from a form is difficult for me.
How can i choose 2nd radio button from my above code?
Checkbox selection i used code like this ..
$agent->tick('checkboxname', 'value');
and submitting the form, code as $agent->click('FrmButton');
So how can i select a radio button? Pls post a code for this? portion of my html code is given below
<table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr><td width="50%">&nbsp; <input type="radio" value="USAGE CREDIT" na +me="CreditType" checked> Usage Credit</td> </tr> </table> <table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr><td width="50%">&nbsp; <input type="radio" value="ACCT CREDIT" nam +e="CreditType"> Account Credit</font></td></tr> </table> <table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr><td width="50%">&nbsp; <input type="radio" value="PAYMENT" name=" +CreditType" > Payment</td><td width="50%"></td> </tr> </table> <table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr><td width="50%">&nbsp; <input type="button" value="Submit" name=" +Frmbutton" ></td> </tr> </table>

Thanks in advance

20030718 Edit by Corion: Changed bold to code

Replies are listed 'Best First'.
Re: Select a Radio button using WWW::Mechanize module
by Corion (Patriarch) on Jul 18, 2003 at 07:50 UTC

    For radio buttons, you want to set the value of the element. Untested code follows, as I haven't updated WWW::Mechanize::Shell to read in HTML from non-http- sources.

    $agent->current_form->value("CreditType", "PAYMENT");
    perl -MHTTP::Daemon -MHTTP::Response -MLWP::Simple -e ' ; # The $d = new HTTP::Daemon and fork and getprint $d->url and exit;#spider ($c = $d->accept())->get_request(); $c->send_response( new #in the HTTP::Response(200,$_,$_,qq(Just another Perl hacker\n))); ' # web
      hi, i am using mechanize module, i want to select radio button uing this module. it will automatically select the radio button and proceeds the next step can help regading this. thanks chandrashekar paga