in reply to Win32::IE::Input

Win32::IE::Form and Win32::IE::Input are Perl copies of IE objects, and they don't provide methods to modify their IE counterparts. You'll need to access the Document and add the field to it just as you would in JavaScript.

# Select the form my $perl_form = $ie->form_name('form1'); # Get a pointer to IE's DOM object. my $form = ${$perl_form};

$form is IE's object for the form. It's an instance of a DOM form.

Untested example:

my $doc = $ie->Document; my $form = ${$ie->form_name('...')}; my $field = $doc->createElement('<INPUT TYPE="hidden">'); $field->name = '...'; $field->value = '...'; $form->appendChild($field);

$doc is a DOM document.
$form is a DOM form.
$field is a DOM hidden input.

I'd love to hear how well this works.

Updated: Added more info. Rephrased in order to intergrate new info.

Replies are listed 'Best First'.
Re^2: Win32::IE::Input
by thekestrel (Friar) on Jul 14, 2005 at 22:26 UTC
    Ikegami,
    Thanks for the reply. A little bit of tweaking, but you were pretty much on the money =).
    my $doc = $ie->agent->Document; my $form = ${$perl_form}; my $field = $doc->createElement('<INPUT NAME="FLUFFY" VALUE="socks" TY +PE="hidden">'); $form->appendChild($field); my @inputs = $perl_form->inputs(); my $c = 1; foreach my $i ( @inputs ) { print "Input$c : " . $i->name . " : " . $i->value . " : " . $i +->type . "\n"; $c++; }

    The $doc just needed an agent slapped in the middle and with field I could only get it to work when I added all the data in one line, but I didn't tinker with it too much.
    Update: looked into it a bit more you can do the field definition with the following...
    ... my $field = $doc->createElement('<INPUT TYPE="hidden">'); %{$field}->{name} = "FLUFFY"; %{$field}->{value} = "socks";

    Which gives....
    Input1 : Fruit : apple : hidden Input2 : Animal : dog : hidden Input3 : language : perl : hidden Input4 : FLUFFY : socks : hidden
    Thanks for your help ++. =)

    Regards Paul