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

Hi Monks, have a small Issue with mechanize. My target source code didn't have a "name" field associated with it. but its having "id" and "class".

Target source code look like this

<select id="keyword-country-option" class="dropdown"> <option value="Choose Location">Choose Region< +/option> <option value="AMEA">Asia, Middle East &amp; A +frica</option> <option value="Canada">Canada</option> <option value="Europe">Europe</option> <option value="Latin America">Latin America</o +ption> <option value="United States">United States</o +ption> </select>

I wish to use $mech->select($name, $value); Is there any way to achieve this..? Thank you.

Replies are listed 'Best First'.
Re: Mechanize select with "id" or "class" other than "name".
by Corion (Patriarch) on Nov 12, 2012 at 09:39 UTC

    ->select uses HTML::Form->find_input, so you should be able to specify an id by using a # prefix:

    $mech->select('#keyword-country-option', 'Canada');

      Thank you...