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

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

Reply via email to