Re: Problems with a Submit Input Requiring a Value

"Gisle Aas" <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.lwp
Message-ID <[email protected]>
On Tue, Jun 17, 2008 at 6:42 PM, Hal Vaughan <[email protected]> wrote:
> I've never seen this before so it could be I'm outdated, but I'm reading a
> page that has two submit buttons in one form.  Here's the code for both of
> them:
>
> <input type="submit" name="caseSearch" value="Search" onclick="return
>        validateCaseNumber();" class="payBox">
> <input type="submit" name="paymentCaseSearch" value="Search To Pay"
>        class="payBox longBox">
>
> I've used Wireshark and Firefox to track the POST data that is sent out when
> POSTing this form back to the server.  When I click on the caseSearch
> submit button in Firefox, it includes the value pair "caseSearch=Search" in
> the POST data that goes back to the server.
>
> When I use WWW::Mech to submit, that is not sent as POST data.  I've tried
> to force it by setting the value to Search, but it was already at that
> value and it's not included.

I think you need to demonstrate the problem with some runnable sample
code.  When I test it here it seems to do the right thing:

#!perl -w
use strict;
use HTML::Form;

my $f = HTML::Form->parse(<<'EOT', "http://example.com");
<form method="POST">

<input type="submit" name="caseSearch" value="Search" onclick="return
       validateCaseNumber();" class="payBox">
<input type="submit" name="paymentCaseSearch" value="Search To Pay"
       class="payBox longBox">

</form>
EOT

#$f->dump;
print $f->click("caseSearch")->as_string;
__END__

When I run this program it prints:

POST http://example.com
Content-Length: 17
Content-Type: application/x-www-form-urlencoded

caseSearch=Search

Regards,
Gisle
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.