Jeff,
The mailing list archive mentioned in my first append is -
http://www.ics.uci.edu/pub/websoft/libwww-perl/archive/2000h2/0485.html
There seems to be another problem where if I try to
read the value of a checkbox that is unchecked, the
value returned is null ...
#!/usr/bin/perl -w
use URI::URL;
use LWP::Simple ;
use HTML::TokeParser;
use LWP::UserAgent;
use HTTP::Request::Common;
use HTML::Form;
my $ua = LWP::UserAgent->new;
my $r = $ua->simple_request(POST "http://myurl/mycgi.pl",
{
SellerID => 'myid',
password => 'mypass',
});
@forms = HTML::Form->parse($html,'http://myurl.com');
@all_input = $forms[2] -> inputs;
for($i=1; $i < $#all_input + 1; $i += 1) {
$name = $all_input[$i]->name;
$value = $all_input[$i]->value;
$type= $all_input[$i]->type;
}
Printing $value for an unchecked checkbox prints nothing.
All other attributes print file. Printing $value for a
checkbox that's checked works fine.
I need to look at the value, then determine if the input is unchecked,
then check it, then submit the form.
Does this sound like a bug to anyone or am I still doing something wrong ?
If so, do you know of another package I can use to accomplish this simple
task ?
Thanks,
Steve
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, August 28, 2001 8:50 PM
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: Re: Manipulating input states with HTML::Form
Steve,
I'm not sure what doc in the mailing list archive you mention, but I did
find this at http://groups.yahoo.com/group/libwww-perl/message/6616:
"There is a unchecked variable in HTML::Form that causes -w to complain if
you try to "uncheck" a checkbox... (ie: when you list the values of a
form, it has "on" and "undef" as the possible options for a checkbox, if
you try to set it to "undef" to uncheck it, it works ok, but -w complains
about use of undefined value in Form.pm)"
Does this sound like the error you're getting?
-- Jeff
On Tue, 28 Aug 2001 [EMAIL PROTECTED] wrote:
> Jeff,
>
> Thanks for your reply.
> Do you know where I can find doc describing the "checked" attribute ?
> Or better yet some examples of this type of form input manipulation.
>
> This seems to be a rather undocumented/confusing way to handle a very
> simple concept. Then again I'm probably not looking at the right
> documentation. The sample I found in the mailing list archive threw
> me as it uses value and undef to turn the input "off". I guess
> I missinterpreted "off" as meaning unchecked.
>
> An example of evaluating a checkbox's text value then testing if it's
> "checked", then checking it (turning it ON) if it isn't, would be
extremely
> helpful. Maybe I can provide one if I ever get this foolish thing to work.
>
> Thanks,
> Steve
>
>
> > The value can be defined with the box not being checked; it's two
separate
> > properties. So making the value undef won't uncheck the box, it will
just
> > make a useless checkbox in the sense that even if it's checked nothing
> > gets sent to the server. If it's checked then the value gets sent to
the
> > server.
> >
> > Have you tried it using the checked attribute instead of value?
> >
> > -- Jeff
> >
>
> pop-server.stny.rr.com
>