in reply to Re: LWP multi-form POST
in thread LWP multi-form POST

A lot of sites use javascript to submit multiple forms

Can you site an example of a site that does this? (I'm not denying it -- I've seen all sorts of weird things done with scripts that ought not to be possible. I'm just curious how it's accomplished, given that normally the submission of a form causes the browser to stop executing the scripts on that page as it goes on to fetch the new form-result page.)

Basically, if you use a <form NAME="foo"> tag in the forms declaration you can use:

document.foo.submit();

To submit a form. Most of the time this is used to create hyperlinks which submit a form, or forms that submit themselves if you click on a select box, for instance. However, it can be extended by creating a class of functions to submit multiple forms at the same time. I don't have any examples off the top of my head, but if I come across one I will be sure to post it.


Want to support the EFF and FSF by buying cool stuff? Click here.

Replies are listed 'Best First'.
Re: LWP multi-form POST
by jonadab (Parson) on Feb 11, 2004 at 14:33 UTC
    document.foo.submit();

    Yeah, that much I'm familiar with; I've personally seen examples of sites that use scripts to submit forms. This is no problem for scripting, because instead of executing the script you just submit the form. Sometimes the script does some other things before it submits the form, such as changes some field values. In that case, you just do that first, then submit the form.

    However, it can be extended by creating a class of functions to submit multiple forms at the same time.

    That's what I haven't seen and wouldn't know how to do. (How do you stop your script from ceasing to execute when the first form is submitted? Or is Javascript multithreaded these days? Where do the extra result pages go, then? Do they pop up in extra windows, or what?) Anyway, that's some pretty weird stuff, submitting multiple forms at once. Sites ought not to do such things. Sometimes I wish LiveScript had never been developed.


    $;=sub{$/};@;=map{my($a,$b)=($_,$;);$;=sub{$a.$b->()}} split//,".rekcah lreP rehtona tsuJ";$\=$ ;->();print$/
      There are probably a thousand different ways to manage it depending on what exactly you are trying to do. Javascript can open up windows and control the windows. So you can open a window, submit several forms there, and close it -- or even submit the last form there. You can also use some black magic on the server side, or a thousand other things. Go to Expedia.com and walk through the javascript it takes you to get to the "My Profile" link for an example. It doesn't submit any forms, but (perhaps to foil spiders) sets cookies and then does a document.location = newURL to jump from page to page. Things like this aren't common, but they are out there to spoil spiders on sites that have a reason to not want their sites spidered -- i.e. ebay, paypal, similar sites.


      Want to support the EFF and FSF by buying cool stuff? Click here.