in reply to WWW::Mechanize and disabled form field

The problem is that disabled form fields do not get submitted when the form is submitted, they are completely ignored by browsers, so HTML::Form is also not submitting them. You already have a method call to find a field and force a value:

$m->form_name("form1")->find_input("MakeID")->force_value("32");

I looked at the HTML::Form documentation and there is a method called disabled() that you can use to toggle the "disabled" flag on a form field. So I added this to your code:

$m->form_name('form1')->find_input('MakeID')->disabled(0);

And then submitted it using mechanize, and I got back a list of volkswagons.

The tricky part is that although the field is disabled by default, somewhere along the way, their javascript enables it. To use mechanize on javascript-enabled sites, you really have to look at what's being submitted to the server when you press submit on your browser, then you have to use mechanize to emulate that.

Replies are listed 'Best First'.
Re^2: WWW::Mechanize and disabled form field
by goldfish_ (Initiate) on Nov 19, 2007 at 09:46 UTC
    Ah I see, thanks for the tips guys, i'll get to grips with wireshark and WWW::Mechanize::Shell for testing these things. Thanks alot.