Thanks to all for helping me understand the use of the "value"
attribute as it applies to querying the form inputs as opposed
to the HTML value tag.

I was able to implement a solution based on the samples provided
except for the use of the "possible_values" method. I got the
following error msg when using it ....

Can't locate object method "possible_values" via package
"HTML::Form::ListInput"

Possibly my hosting service has an outdated copy of the HTML::Form module ?

I tried using  "other_possible_values" and was able to get by with
that (at least for now).

Thanks again for the assistance, code samples and patience.

Steve

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of Gisle Aas
Sent: Wednesday, August 29, 2001 2:59 AM
To: steve borruso
Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: Re: Manipulating input states with HTML::Form


"steve borruso" <[EMAIL PROTECTED]> writes:

> Printing $value for an unchecked checkbox prints nothing.

You get a warning if you turn on -w as you try to print undef.

> I need to look at the value, then determine if the input is unchecked,
> then check it, then submit the form.

I modified Tim's sample code a bit to suit your need.  Hope it helps...

#!/usr/bin/perl -w

use strict;
use HTML::Form;
my $html = join('',<DATA>);

my $form = HTML::Form->parse($html,'http://localhost');
print $form->dump,"\n";

for my $input ($form->inputs) {
    next unless $input->type eq 'checkbox';
    next if defined $input->value;  # already checked, skip
    $input->value(($input->possible_values)[-1]);  # check it
}

print $form->dump,"\n";

# submit the form...
#print $ua->request($form->click)->as_string;

__DATA__
<html>
<form action="foo" method="post">
<input type="text" name="who"><br>
<input type="checkbox" name="color" value="blue"> Blue
<br>
<input type="checkbox" name="color" value="red" checked> Red
<br>
<input type="checkbox" name="color" value="green"> Green
<br>
</form>
</html>

Reply via email to