submitting a form when two forms with the same name

Discussion in 'Perl Misc' started by Nospam, Feb 3, 2008.

  1. Nospam

    Nospam Guest

    Trying to submit the second form, when there are two forms on the page both
    called "submit" using www::Mechanize and Html::Form

    the first form html is: <input type="submit" name="submit" value="Go" />

    The second form's: <input type=submit name=submit value=" S E N D ">

    #After filling in my login details with and getting positive checks for
    username and password filled in:

    #! /usr/bin/perl
    use strict;
    use warnings;
    use WWW::Mechanize;


    my $mech WWW::Mechanize->new();

    $mech->get("http://localhost/login.cgi");

    foreach($mech->forms()){
    if (defined $_->find_input('username'))
    $_->value('username',"username");
    if($mech->success){print "Username filled in \n";}else{print " $! \n"}
    $_->value('password',"password");
    if($mech->success){print "password filled in \n";}else{print " $! \n"}

    }
    }

    $mech->submit("submit"); #I have also tried $_->click("submit"); but all
    submitted the first form and not the second
     
    Nospam, Feb 3, 2008
    #1
    1. Advertising

  2. Nospam

    Ben Morrow Guest

    Quoth "Nospam" <>:
    >
    > Trying to submit the second form, when there are two forms on the page both
    > called "submit" using www::Mechanize and Html::Form
    >
    > the first form html is: <input type="submit" name="submit" value="Go" />
    >
    > The second form's: <input type=submit name=submit value=" S E N D ">


    Try

    $mech->click_button(value => ' S E N D ');

    Ben
     
    Ben Morrow, Feb 3, 2008
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?Z2VvZGV2?=

    Re submitting to the same form

    =?Utf-8?B?Z2VvZGV2?=, May 18, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    428
    =?Utf-8?B?QW5keQ==?=
    May 18, 2005
  2. Bjorn

    submitting two forms in same page?

    Bjorn, Jul 28, 2004, in forum: ASP General
    Replies:
    3
    Views:
    148
    Bjorn
    Jul 29, 2004
  3. Pavils Jurjans
    Replies:
    3
    Views:
    194
    Pavils Jurjans
    Mar 18, 2005
  4. Replies:
    6
    Views:
    180
  5. paratge

    Submitting two forms in one click

    paratge, Apr 16, 2007, in forum: Javascript
    Replies:
    4
    Views:
    132
    paratge
    Apr 16, 2007
Loading...

Share This Page