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

On Tue, 28 Aug 2001, steve borruso wrote:

>
> I don't understand how to manipulate the state of a checkbox.
> I can query the name, type, value, etc. of the input.
>
> I based my attempts of turning on a checkbox
> on the following append which indicates
>   $f->value(name => undef); would turn the input "OFF".
>
> http://www.ics.uci.edu/pub/websoft/libwww-perl/archive/2000h2/0485.html
>
> When I attempt to turn the input "ON"  with
> $f->value($name,defined);  the state does not change. No error
> is given when executed. It doesn't seem to matter what I use in
> place of "defined". It doesn't appear that I'm changing the
> value of the input (as opposed to the state) with what I use either.
>
> I've studied the HTML::Form doc along with the Perldoc and still
> can't seem to get it right.
>
> Can someone please take a look at the code sample below
> and point out the logic error and/or provide another example that
> might help.
>
> Thanks in advance !
> Steve
>
> boiled down sample of my code ....
>
> @forms = HTML::Form->parse($html,'http://myurl.com');
>
> @all_input =  $forms[2] -> inputs;
>
> for($i=1; $i < $#all_input + 1; $i += 1) {
>
>    $type=   $all_input[$i]->type;
>    $value = $all_input[$i]->value();
>    $name =  $all_input[$i]->name();
>
>      if (defined $all_input[$i]->value)   {
>         print "<br> it is on";
>       }
>       else {
>             print "<br> turning it on <br>";
>             $forms[2]->value($name,defined);
>             if (defined $all_input[$i]->value)   {
>                print "<br> STATE SHOULD NOW BE CHECKED (ON)";
>             }
>       }
> }
>
>

Reply via email to