Hi all,

  I have been working on a program that traverses the website of a third party company, so I have no influence on or information about the page. I've been able to successfully tick checkboxes before, but in this case there is a twist.

  The page has an input value of:

<input type="checkbox" name="selrow0" value=" " onclick="clicksel(this +)">
  And the 'clicksel' JS function is:
function clicksel( itm ) { if (itm.checked) { if ((document._LocationSelection.sel.value != itm.name ) && ( +document._LocationSelection.sel.value != "")) { box = eval("document._LocationSelection." + document._Loca +tionSelection.sel.value); box.checked = false; } else { document._LocationSelection.sel.value = itm.name; } } else if (document._LocationSelection.sel.value == itm.name) { document._LocationSelection.sel.value = ""; } }
  As I understand it, the JS sets the value of the checkbox to the name of the checkbox that was ticked and unchecks any others. However, looking through WWW::Mechanize (and HTML::Form) it looks like it expects the input value (space, in this case). Why didn't they use radio? Anyway...
my $input = $agent->current_form->find_input("selrow0", 'checkbox', 0) +; $input->value("selrow0");
  And several variants of cause an error like this:
Illegal value 'selrow0' for field 'selrow0' at ./check_avail.lib line +285
  The '$input->value("selrow0");' being line 285 in this example.

  I've tried several different things, including directly accessing and changing the checkboxes object in WWW::Mechanize ('current', 'name' and 'value' hash values, specifically), but in all cases when I submit the form I get an error saying that I didn't check any boxes (error from the remote website).

  I've bashed my head against the wall on this so much that it's now flat enough to use as a table top... Help?

Digi

PS - Perl 5.8.8 on Ubuntu (devel) and Debian (server), in case it matters.

In reply to Ticking checkboxes in WWW::Mechanize, with a twist by Digimer

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.