JavaScript and Automating form submission

Giganews Newsgroups
Subject: JavaScript and Automating form submission
Posted by:  Charles Banas (none…
Date: Mon, 28 Jul 2003

weird subject - i hope more than just one curious regular will hear me out.

ok, i've got a bit of a big problem, and i need answers as soon as

i know this forum is meant for web developers, but is relevant discussion.
i'm not OT here unless someone thinks i'm trolling (which i'm not,
obviously).  then i'll disappear and never show my face again.  :P

we are automating form submission using the MS IE 5 DOM through the
InternetExplorer object and have run against two major roadblocks: both of
which involve JavaScript and the DOM exposed in Internet Explorer, so i
hope someone can help out here.

first, and easiest, we will need to be able to upload files assosciated
with this form sumbission.  we'd like to automate it, like everything else.
my question here is:  how do we assign a file to an input field of type
"file" to upload it?

second, and more difficult:  the forms use a validation script that ensures
proper content in the form.  it's difficult to ensure all our data will
pass the validation, so we would like to be able to flag errors as they
come.  the validation script scans the contents of the form and calls
window.alert() when an error is detected (i.e., missing data or incorrect
data type).  after the alert(), focus() is given to the first field in
question.  this problem is twofold:  we need to detect the alert(), AND we
need to know which input field has focus.  so how do we trap the alert(),
and how do we detect which field got focus()?  (we do, in fact, have a
complete list of possible fields that may gain focus.)

any help would be greatly appreciated, even if it's "go away and ask this
in microsoft.public.inetsdk.*!"  (unfortunately, that's the first place i
tried, and either no one knows or no one wants to answer.)

Charles Banas