You need to specify (uggghh!) the optional $number argument in the field() method:

   The optional "$number" parameter is used to distinguish
   between two fields with the same name.  The fields are
   numbered from 1.
Here is some code to test with. First, the CGI script:
use strict; use warnings; use CGI qw(:standard); print header, start_form, 'Enter something: ', textfield('text1'), checkbox_group( -name => 'checkbox1', -values => [qw(foo bar baz qux)], ), submit('go'), end_form, ; if (param('go')) { print pre(map "$_: @{[param($_)]} \n", param); }
And the Bot to query it with:
use strict; use warnings; use WWW::Mechanize; my $agent = WWW::Mechanize->new(); $agent->get('http://localhost/cgi-bin/foo.cgi'); $agent->form(1); $agent->field(qw(text1 HELO)); $agent->field(qw(checkbox1 foo 1)); $agent->field(qw(checkbox1 baz 3)); $agent->click('go'); print ($agent->{content} =~ /<pre>(.*)<\/pre>/s);
Hope this helps. :)

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)

In reply to (jeffa) Re: WWW::Mechanize and checkboxes by jeffa
in thread WWW::Mechanize and checkboxes by rkg

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.