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

Manipulating input states with HTML::Form

Thread Next
steve borruso
August 28, 2001 06:12
Manipulating input states with HTML::Form
Message ID:

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

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 !
boiled down sample of my code ....  

@forms = HTML::Form->parse($html,'');

@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>";
            if (defined $all_input[$i]->value)   {
               print "<br> STATE SHOULD NOW BE CHECKED (ON)";

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About