Click here to get back home

submitting a form when two forms with the same name

 HomeNewsGroups | Search | About
 comp.lang.perl.misc    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
submitting a form when two forms with the same name Nospam 02-02-2008
Get Chitika Premium
Posted by Nospam on February 2, 2008, 10:54 pm
Please log in for more thread options

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



Posted by Ben Morrow on February 3, 2008, 12:13 pm
Please log in for more thread options

>
> 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


Similar ThreadsPosted
submitting a form with no name attribute with mechanize November 2, 2006, 7:44 pm
problem when submitting a string through a form January 3, 2008, 7:51 am
submitting patch to perl docs March 18, 2007, 5:40 pm
"Enter this obfuscated code before submitting" help needed (CGI) January 9, 2008, 8:03 am
HTTP::Request::Form - Can't submit a form with input type=image button January 31, 2005, 11:42 pm
www::mechanize and forms November 5, 2006, 4:47 pm
sending info to forms November 20, 2004, 1:33 am
Re: sending info to forms November 20, 2004, 1:34 am
forms, cgi - beginner question February 15, 2005, 10:39 am
posting https forms January 9, 2007, 10:36 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap