I concur wholeheartedly with Corion, Ovid's CGI Course is a good start

Also, for every question like this you have, you should write a small program to answer it, like this

#!/usr/bin/perl -- use strict; use warnings; use WWW::Mechanize 1.66; use URI::file; my $ua = WWW::Mechanize->new( autocheck => 1, ); $ua->add_handler( "request_send", sub { $_[0]->dump; return; }, m_method => 'POST' ); $ua->timeout(1); #~ $ua->get( URI::file->new( 'test.html' )->abs(URI::file->cwd) ); $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='checkbox' name='CategoryId25' CHECKED /> <input type="checkbox" name="check" value="1111" >1111 <input type="checkbox" name="check" value="2222" CHECKED>2222 <input type="checkbox" name="check" value="3333" >3333 <input type="checkbox" name="check" value="4444" CHECKED>4444 <input type="checkbox" name="check" value="5555" >5555 <input id="enterbutton" type="submit" name="user_choice" value="Enter" + /> <input type="submit" name="user_choice" value="Leave" /> </form> </body> </html> HTML print '# ', __LINE__, ' ', '#' x 33, "\n"; eval { $ua->submit_form( form_number => 0, fields => {qw' user_choice Enter '}, ); } or print "\n", __LINE__, " $@"; print '# ', __LINE__, ' ', '#' x 33, "\n"; eval { $ua->back; # if autocheck => 0 $ua->form_number(0); #~ $ua->set_fields( check => [ 3333, 5555 ] );# error, checkboxes not +fields $ua->tick( check => 2222 => 0 ); # untick/uncheck $ua->tick( check => 3333 ); # tick/check $ua->untick( check => 4444 ); # uncheck $ua->tick( check => 5555 => 1 ); # check $ua->click_button( value => 'Enter' ); # submit } or print "\n", __LINE__, " $@"; print '# ', __LINE__, ' ', '#' x 33, "\n"; eval { $ua->back; # if autocheck => 0 $ua->submit_form( form_number => 0, fields => { qw' user_choice Enter ', check => 1111, check => 5555, check => 6666, }, ); } or print "\n", __LINE__, " $@"; print $ua->dump_forms,"\n\n"; __END__ $ perl mechanize.inline.submit_form3.pl # 37 ################################# POST http://localhost/ Accept-Encoding: gzip Referer: file:////~/temp/mechanize.inline.submit_form3.pl User-Agent: WWW-Mechanize/1.66 Content-Length: 37 Content-Type: application/x-www-form-urlencoded CategoryId25=on&check=2222&check=4444 43 Error POSTing http://localhost/: Can't connect to localhost:80 (ti +meout) at mechanize.inline.submit_form3.pl line 39 # 45 ################################# POST http://localhost/ Accept-Encoding: gzip Referer: file:////~/temp/mechanize.inline.submit_form3.pl User-Agent: WWW-Mechanize/1.66 Content-Length: 55 Content-Type: application/x-www-form-urlencoded CategoryId25=on&check=3333&check=5555&user_choice=Enter 56 Error POSTing http://localhost/: Can't connect to localhost:80 (ti +meout) at mechanize.inline.submit_form3.pl line 55 # 58 ################################# POST http://localhost/ Accept-Encoding: gzip Referer: file:////~/temp/mechanize.inline.submit_form3.pl User-Agent: WWW-Mechanize/1.66 Content-Length: 48 Content-Type: application/x-www-form-urlencoded CategoryId25=on&check=6666&check=2222&check=4444 70 Error POSTing http://localhost/: Can't connect to localhost:80 (ti +meout) at mechanize.inline.submit_form3.pl line 61 POST http://localhost/ CategoryId25=on (checkbox) [<UNDEF>/off|*on] check=6666 (checkbox) [:<UNDEF>/off|1111] check=2222 (checkbox) [<UNDEF>/off|*2222] check=<UNDEF> (checkbox) [*<UNDEF>/off|3333] check=4444 (checkbox) [<UNDEF>/off|*4444] check=<UNDEF> (checkbox) [*<UNDEF>/off|5555] user_choice=Enter (submit) user_choice=Leave (submit)

In reply to Re^5: WWW::Mechanize clicking checkboxes by Anonymous Monk
in thread WWW::Mechanize clicking checkboxes by Anonymous Monk

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.