I want to fill out a form on a web app using Perl and LWP::UserAgent.
If the form has multiple check boxes, and I only want to change one of them, do I have to post all of the fields to the form or can I just submit the one field that I want to change?
For example, in this form, all three items are presented as checked: milk, butter, and cheese.
<html>
<head>
<title>My Page</title>
</head>
<body>
<form name="myform" action="/myformhandler.cgi
" method="POST">
<div align="left"><br>
<input type="checkbox" name="option1" value="Milk" checked> Milk<br>
<input type="checkbox" name="option2" value="Butter" checked> Butter<br>
<input type="checkbox" name="option3" value="Cheese" checked> Cheese<br>
<input type="submit" value=submit>
<br>
</div>
</form>
</body>
</html>
If I want to submit the form with cheese unchecked, can I do this?
use LWP::UserAgent;
my $ua = LWP::UserAgent->new;
$ua->agent("Mozilla 8.0");
use
HTTP::Request::Common qw(POST);
my $req = (POST '
http://perl.noobs.com/myform.cgi',
[ option3 => 'off',
]);
my $request = $ua->request($req);
Or do I have to submit all form items like this?
use LWP::UserAgent;
my $ua = LWP::UserAgent->new;
$ua->agent("Mozilla 8.0");
use
HTTP::Request::Common qw(POST);
my $req = (POST '
http://perl.noobs.com/myform.cgi',
[ option1 => 'on',
option2 => 'on',
option3 => 'off'
]);
my $request = $ua->request($req);