Yeah, most people eventually figure out set_fields or submit_form ... and realize just what a PITA some of the methods can be (esp HTML::Form )

Here is how I test these things

#!/usr/bin/perl -- use strict; use warnings; use WWW::Mechanize 1.66; use URI::file; Main( @ARGV ); exit( 0 ); sub Main { my $ua = WWW::Mechanize->new( autocheck => 1, ); $ua->timeout(0.00000000001); $ua->get( URI::file->new(__FILE__)->abs( URI::file->cwd ) ); $ua->update_html( <<'HTML' ); <html> <head> <title> test.html : localhost form </title> </head> <body> <base href="http://localhost/"> <form method="POST" action="http://localhost/"> <input type="hidden" name=r0 value=0 disabled>zero <input type=radio name=r1 value=1 disabled>one <input type=radio name=r1 value=2>two <input type=radio name=r1 value=3>three <input type=radio name=r2 value=1>one <input type=radio name=r2 value=2 disabled>two <input type=radio name=r2 value=3>three <input type="submit"> </form> </body> </html> HTML print $ua->dump_forms,"\n\n"; $ua->set_fields( qw' r1 three r2 three r3 three '); print $ua->dump_forms,"\n\n"; $ua->set_fields( qw' r2 7 '); print $ua->dump_forms,"\n\n"; $ua->add_header( Referer => undef ); $ua->add_handler( "request_send", sub { $_[0]->dump; return; }, m_method => 'POST' ); $ua->submit(0); $ua->delete_header( 'Referer' ); } __END__ $ perl mechanize.radio.pl POST http://localhost/ r0=0 (hidden disabled readonly) r1=<UNDEF> (radio) [-1/one|2/two|3/three] r2=<UNDEF> (radio) [1/one|-2/two|3/three] <NONAME>=<UNDEF> (submit) POST http://localhost/ r0=0 (hidden disabled readonly) r1=3 (radio) [-1/one|2/two|*3/three] r2=3 (radio) [1/one|-2/two|*3/three] <NONAME>=<UNDEF> (submit) r3=three (text) POST http://localhost/ r0=0 (hidden disabled readonly) r1=3 (radio) [-1/one|2/two|*3/three] r2=7 (radio) [1/one|-2/two|:3/three] <NONAME>=<UNDEF> (submit) r3=three (text) POST http://localhost/ Accept-Encoding: gzip User-Agent: WWW-Mechanize/1.66 Content-Length: 18 Content-Type: application/x-www-form-urlencoded r1=3&r2=7&r3=three Error POSTing http://localhost/: Can't connect to localhost:80 (timeou +t) at mechanize.radio.pl line 63

In reply to Re^3: click radio button with WWW::Mechanize by Anonymous Monk
in thread click radio button with WWW::Mechanize by Niner710

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.