Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Clicking nameless buttons with WWW::Mechanize

by jbrugger (Parson)
on Mar 15, 2005 at 05:12 UTC ( #439547=note: print w/replies, xml ) Need Help??


in reply to Clicking nameless buttons with WWW::Mechanize

I'm a bit confused what you exacly mean, please correct me if i'm wrong. You have 2 forms in one page, and want the submit button to submit the proper form?
When using:
<form action="javascript:alert('1')"> <input type=submit /> </form> <form action="javascript:alert('2')"> <input type=submit /> </form>
It seems to work fine for me, i just can have a different action per form, and the button submits the form it is in.
update
Ah i see...
try:
$mech->submit_form( form_number => 1, fields => { username => 'mungo', password => 'lost-and-alone', } ); # as from $mech->submit_form( ... ) # If button is not passed, then the submit() method is used instea +d.
Its described here

Replies are listed 'Best First'.
Re^2: Clicking nameless buttons with WWW::Mechanize
by bobf (Monsignor) on Mar 15, 2005 at 05:45 UTC

    Thanks for the reply. At first I thought that would work, too. Specifically, I tried:

    $mech_obj->submit_form( form_number => 2, fields => { 'username' => $username, 'password' => $password } );

    But I got the same result as when I used the submit method directly: the search box (form 1) was submitted instead (despite form 2 being selected). Thanks for trying, but I'm still looking for a solution.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (7)
As of 2020-06-05 19:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you really want to know if there is extraterrestrial life?



    Results (40 votes). Check out past polls.

    Notices?