What you mean terribly written HTML? I's a valid XHTML tag. I expected you put the code with WWW::Mechanize and pointed out which part didn't work as you expect. But OK, supposed we have a HTML file (form.html) with the following simplified content:
<form> <input type="checkbox" name="passenger" value="somevalue" /> <input type="submit" name=".submit" value="OK"> </form>
Update: (21-06-2007) Oops, fixed the submit field.

The following example (tick.pl) demonstrates the checkbox ticking.

use strict; use warnings; use WWW::Mechanize; # set some dummy vars my $target_field = 'passenger'; my $target_value = 'somevalue'; # get the URL and check my $url = shift or die "Need URL, pal!\n"; my $mech = WWW::Mechanize->new; $mech->get($url); $mech->success or die $mech->response->status_line, "\n"; # select the form $mech->form_number(1); # check original value my $set_value = $mech->value($target_field); $set_value = 'undef' unless defined $set_value; print "[1] value for $target_field: ($set_value)\n"; # tick the checkbox $mech->tick($target_field, $target_value); $set_value = $mech->value($target_field); $set_value = 'undef' unless defined $set_value; print "[2] value for $target_field: ($set_value)\n";
And supposed that the form URL is http://localhost/form.html, the program produces the following when run:
$ perl tick.pl http://localhost/form.html [1] value for passenger: (undef) [2] value for passenger: (somevalue)
HTH,

Open source softwares? Share and enjoy. Make profit from them if you can. Yet, share and enjoy!


In reply to Re: WWW::Mechanize on broken HTML by naikonta
in thread WWW::Mechanize on broken HTML by gecko

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.