develooper Front page | perl.libwww | Postings from August 2001

Manipulating input states with HTML::Form

Thread Next
From:
steve borruso
Date:
August 28, 2001 06:12
Subject:
Manipulating input states with HTML::Form
Message ID:
000001c12fc0$b3272d40$6501a8c0@stny.rr.com

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

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About