can"t use www:mech set_fields for a select field.
am 13.12.2004 11:58:31 von burcu------=_NextPart_000_010E_01C4E113.74752900
Content-Type: text/plain;
charset="iso-8859-9"
Content-Transfer-Encoding: 7bit
Hi there,
Someone please help me with this.
I'm trying to select value from two select boxes and submit the form. But
the select boxes are filled via javascript codes. The source code looks like
this:
................
id="productSearch1_lbCategories" class="urun_arama_field"
OnChange="lbCategories_onChange();" style="width:150px;">
id="productSearch1_lbSubcategories" class="urun_arama_field"
OnChange="lbSubcategories_onChange();" style="width:150px;">
..............
............
I know what values to send via this select boxes but unfortunately I can't
set them to those values.
I tried:
$mech -> form_name(Form1);
$mech -> select('productSearch1:lbCategories', $_[0]);
$mech -> select('productSearch1:lbSubcategories', $_[1]);
$mech -> submit();
which yields
input 'productSearch1:lbCategories' not found
input 'productSearch1:lbSubcategories' not found
and
$mech -> form_name(Form1);
$mech -> set_fields('productSearch1:lbCategories' => $_[0],
'productSearch1:lbSubcategories' => $_[1],);
$mech -> submit();
which yields
No such field 'productSearch1:lbSubcategories'
I'm not sure if I can use set_visible.
I came across the same problem in another site but then I solved my problem
by writing the values with the URL. (.../search.aspx?category=XYZ&brand=XYZ)
but this time the form method is POST. So that trick doesn't work:-(
Anyone have any idea how to send these input values? Thanks in advance.
------=_NextPart_000_010E_01C4E113.74752900--
Re: can"t use www:mech set_fields for a select field.
am 15.12.2004 12:15:31 von peter.stevensHi Burcu.
I wish Mechanize could handle javascript. It would make some things so
much easier!
Based on your description, it sounds like either the input field is not
named what you think it is, or for some reason, HTML::Form doesn't want
you to address the field by name (are there limitations to the
characters allowed in a form name?).
You can use $form = $mech->form_name($name) to manipulate the form
object directly. This gives you more methods than Mechanize supports.
I would try the $input = $form->find_input method to scan through the
input fields, then you can determine what names HTML::Form thinks are
present or use the $input->value($new_value) method to set the field
without using the name.
Hope this helps.
Best regards
Peter
>
>
RE: can"t use www:mech set_fields for a select field.
am 20.12.2004 14:28:55 von burcuHi Peter,
Thank you for the help. I just had time to try it, was working on other
stuff.
Anyway, find_input doesn't work either. My code :
$form =3D $mech -> form_name(Form1);
@inputs =3D $form -> find_input();
foreach $input ( @inputs) {
print ">>$input->{name}<<\n";
}
only prints the input text boxes and selects that has option tags in
between. The input select box I try to use is=20
< select name=3D"productSearch1:lbCategories" size=3D"10" =
multiple=3D"multiple"
id=3D"productSearch1_lbCategories" class=3D"urun_arama_field"
OnChange=3D"lbCategories_onChange();" style=3D"width:150px;" >
< / select >
So find_input doesn't get it:(
I can't use $input->value($new_value) on this undefined input.=20
I think I'll give up using mech and do my job manually for this site:)
Thank you anyway.
B.
-----Original Message-----
From: Peter Stevens [mailto:peter.stevens@ch-open.ch]=20
Sent: Wednesday, December 15, 2004 1:16 PM
To: Burcu Gümüþ Demokan
Cc: libwww@perl.org
Subject: Re: can't use www:mech set_fields for a select field.
Hi Burcu.
I wish Mechanize could handle javascript. It would make some things so=20
much easier!
Based on your description, it sounds like either the input field is not=20
named what you think it is, or for some reason, HTML::Form doesn't want=20
you to address the field by name (are there limitations to the=20
characters allowed in a form name?).
You can use $form =3D $mech->form_name($name) to manipulate the form=20
object directly. This gives you more methods than Mechanize supports.
I would try the $input =3D $form->find_input method to scan through the=20
input fields, then you can determine what names HTML::Form thinks are=20
present or use the $input->value($new_value) method to set the field=20
without using the name.
Hope this helps.
Best regards
Peter
> =20
>