[EMAIL PROTECTED] writes:
> > Could you provide a complete demo of the problem? Perhaps with a
> > minimized example of the HTML you have problems with.
> >
> > Regards,
> > Gisle
> >
>
>
> Sure . Here is the snippet I have been having problem with : ($local_url will
> have the following value after I extract the links in the main page using
> LinkExtor. As you can see, infact the stnid parameters is already being
> passed in as part of the URL string , but when I list the current values of
> the fields 'stnid' fields shows the default, which is "Please select a
> station", and it doesn't have the Port Chicago station as selected earlier!!)
>
> If you point the browser to the following $local_url, what you will see is
> the page that already shows the station selected..
The reason is that the HTML of this page tells us that "Please select a
station" is to be the selected one:
<SELECT NAME="stnid" onchange="refresh()">
<OPTION SELECTED>Please select a station
<option value=1611400+Nawiliwili,+HI+> 1611400 Nawiliwili, HI
<option value=1612340+Honolulu,+HI+> 1612340 Honolulu, HI
...
</SELECT>
But then if use JavaScript to set the form element.
<SCRIPT>
form.stnid.options[form.stnid.selectedIndex].text = "9415144 Port Chicago, CA";
</SCRIPT>
HTML::Form will not try to execute JavaScript code. If you look at
the page as it loads in a browser you will see that "Please select a
station" is first selected, but is later changed to "Chigago" when the
page load finishes.
> $local_url =
>
>'http://www.co-ops.nos.noaa.gov/cgi-bin/plotqry.cgi?stnid=9415144+Port+Chicago,+CA&flag=1'
>
> ...
> $res = $ua->request(HTTP::Request->new(GET => $local_url ) );
> if ( $res->is_success )
> {
> #print $res->content;
>
> my @forms = HTML::Form->parse($res->content,$res->base);
> my $form;
>
> foreach (@forms)
> {
> $form = $_;
> if ($_->action =~ /get_plot.cgi/)
> {
> print " Found form that contains the action script!\n";
> last;
> }
> }
>
> if ($form){
> print "Form Obtained : \n";
> print $form->form;
>
> $form->value('Action','Wind');
> $form->value('stnid',"9415144 Port Chicago, CA"); # HERE is the error
If you set it as
$form->value('stnid',"9415144+Port+Chicago,+CA+")
then it appears to work as it should.
> #&ListInputs($form);
> my $req = $form->click;
> $res = $ua->request($req);
>
> if ($res->is_success)
> {
> print "Successful click..!\n";
> print $res->content;
> }
>
> }
> -------
>
> Now, when I don't attempt to change the value of the 'stnid' field, and leave
> it as it was , and lick the form. I get an HTML output saying there is not
> plot available :
>
> "
> Sorry...there is no Wind Plot for today available at this time for
> <br>Please select a station</h3>
> "
>
> See that the plot server script did not receive the "Port Chicago" station,
> and got the unselected option whose value stays at "Please select a station"
Regards,
Gisle