stanislav5000 has asked for the wisdom of the Perl Monks concerning the following question:

Using www::mechanize, would this be the proper way to check if a field is a <SELECT> field, rather than a text input box:
if($inputfield =~ /(F|f)ieldname/) { print "matched Fieldname regex\n"; if($inputfield->type=="option") { $mech->select($inputfield=>$desired_input); } else { $mech->set_fields($inputfield=>$desired_input); }
Thanks!

Replies are listed 'Best First'.
Re: HTML options input field question
by cormanaz (Deacon) on Mar 30, 2007 at 18:57 UTC
    Looks like a select field is a ListInput object (you cen determine this with ref) with type option.
    #!/usr/bin/perl -w use strict; use WWW::Mechanize; my $mech = WWW::Mechanize->new(); $mech->get('http://www.google.com/advanced_search?hl=en'); foreach my $inp (@{ $mech->{form}->{inputs} }) { print ref($inp),"\t$inp->{type}\t$inp->{name}\n"; }
    Cheers....Steve