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.