Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

(jeffa) Re: WWW::Mechanize and checkboxes

by jeffa (Chancellor)
on Apr 23, 2003 at 23:43 UTC ( #252716=note: print w/ replies, xml ) Need Help??


in reply to WWW::Mechanize and checkboxes

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)


Comment on (jeffa) Re: WWW::Mechanize and checkboxes
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://252716]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (12)
As of 2014-09-17 15:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (90 votes), past polls