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

Hi there,

I just can't get it to work!
I have basically the following form:
<form name="CFForm_1" action="index.php?loc=admin" method="Post""> <input type="hidden" name="import_users" value="1"> <input type="hidden" name="ID" value="1129"> <SELECT name="userStatus"> <option value="7561">Staff</option> <option value="7560">Other</option> </SELECT> <td><input type="radio" name="importtype" value="1">One</td> <td><input type="radio" name="importtype" value="2">Two</td> <input type="Submit" value="Datei importieren" name="add"> </form>
I tried some ways to 'select a field' and to 'set the radio button', but no matter what I try, it won't work. Can somebody show me how it's done correctly?

Thanks,
Finch.

Replies are listed 'Best First'.
Re: WWW::Mechanize with <SELECT> and radio button
by jettero (Monsignor) on Oct 23, 2007 at 18:31 UTC

    It doesn't seem all that hard to me. It probably looks something like this:

    $mech->submit_form( form_name => "CFForm_1", fields => { userStatus=>"Staff", # etc } );

    In fact, there's an example in the synopsis on the WWW::Mechanize page that shows something like that. It even preserves those hidden params for you automatically. majik. What in particular didn't work?

    -Paul

      That's what I tried and of course I read about the module on CPAN.
      After I 'click' the button, the upcoming page shows me what options have been selected. And it always says, that no/the default option has been selected.
      Here's my code:
      $mech->submit_form( form_name => "CFForm_1", fields => {import_users => "1", userStatus => "7561", #<Select> importtype => "2", #radio button ID => "2"}, button => "add");
        The reason I suggested not filling out the hidden params is to avoid transcription errors. Unless you have a reason to change ID to 2, I'd just leave that alone and mech will carry your ID over for you.

        -Paul

Re: WWW::Mechanize with <SELECT> and radio button
by Anonymous Monk on Oct 24, 2007 at 10:41 UTC
    maybe your version is outdated?