473,386 Members | 1,763 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

JavaScript and Automating form submission

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
possible.

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
Jul 20 '05 #1
6 4305
In article <op**************@news.cableone.net>, Charles Banas
<no****@myplace.net> writes:

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
possible.

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?
In normal security environments, you don't. Its off-limits to scripting. An
ActiveX *might* be able to, but never seen one that would that didn't require
down in the dirt, have your way with my PC security settings.
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.)


Pass a reference to the element to your function. If you are calling the
function from each field, onchange, instead of onchange="someFunction()", use
onchange="someFunction(this)" and it will tell the function, anonymously, what
element called it:

function someFunction(formField){
//validation here
if (passes){

}
else{
window.alert(.......)
formField.focus()
}
}

If the validation function is being called by the onsubmit handler, then it has
to go through all fields, and should know when the field fails, and be able to
know what field needs focus.

If none of this applies, doesn't help, or confuses you, post a very brief
sample page that shows the basics of the page you are actually using. URL
preferred to code.
--
Randy
All code posted is dependent upon the viewing browser
supporting the methods called, and Javascript being enabled.
Jul 20 '05 #2
On 29 Jul 2003 00:08:21 GMT, HikksNotAtHome <hi************@aol.com> wrote:
In normal security environments, you don't. Its off-limits to scripting.
An
ActiveX *might* be able to, but never seen one that would that didn't
require
down in the dirt, have your way with my PC security settings.
since we don't have time to develop such a plugin, do you know of one we
could use? or is it as impossible as it looks?

Pass a reference to the element to your function. If you are calling the
function from each field, onchange, instead of onchange="someFunction()",
use
onchange="someFunction(this)" and it will tell the function, anonymously,
what
element called it:
i guess i wasn't clear enough about it - this isn't our page we're
automating, so i can't really change anything on the page itself. :) it's
being done remotely though the InternetExplorer automation object. (which
really isn't all that good for automation.)
function someFunction(formField){
//validation here
if (passes){

}
else{
window.alert(.......)
formField.focus()
}
}
that is similar to how it's handled, but see attached the source.
information that could be considered "sensitive" has been changed. the
page itself remains unchanged.
If the validation function is being called by the onsubmit handler, then
it has
to go through all fields, and should know when the field fails, and be
able to
know what field needs focus.
unfortunately, that doesn't apply since you're assuming something i didn't
clarify enough. :P
If none of this applies, doesn't help, or confuses you, post a very brief
sample page that shows the basics of the page you are actually using. URL
preferred to code.


this is the most "brief" of the pages in question, and it should give you a
good idea what i'm dealing with.

the links are intentionally broken and names removed to protect the victim
(and possibly my job). :P
Jul 20 '05 #3
On Mon, 28 Jul 2003 16:50:20 -0600, Charles Banas <no****@myplace.net>
wrote:
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
I understood it was meant for discussing javascript, but what the
heck...
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?
just do fileelRef.value="moomin..." in a secure environment this
should be no problem.
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()?


Simply override the alert method with your own, which looks to see
what the message was. to catch which has focus, all I can see is to
overide each elements focus method... but it might be easier simply to
change the validation function to tell you directly...

How to override the functions and everything - look at
http://jibbering.com/snufkin/ which does it.

Jim.
--
comp.lang.javascript FAQ - http://jibbering.com/faq/

Jul 20 '05 #4
On Tue, 29 Jul 2003 04:00:58 GMT, Jim Ley <ji*@jibbering.com> wrote:

How to override the functions and everything - look at
http://jibbering.com/snufkin/ which does it.
wait - are you sure that's what that page talks about?
Jim.


--
Charles Banas
Jul 20 '05 #5
On Tue, 29 Jul 2003 10:11:38 -0600, Charles Banas <no****@myplace.net>
wrote:
sorry - to clarify, i'm doing this in Access 97 through the
InternetExplorer "automatin" object. maybe i shouldn't have put
"JavaScript" in the subject....


Automating it with JS or VBA or whatever, the Object Model is the
same, and snufkin shows how to override window methods (not
window.alert specifically) but others to achieve what you want, making
them non-interactive, if you look at Snork an even older piece of code
knocking about on my site, I think you'll even see alert being
over-ridden.

Doing what you want is simple automating IE from JS, I'm sure it will
be simple from VBA too, but VBA is just a muppet language.

Jim.
--
comp.lang.javascript FAQ - http://jibbering.com/faq/

Jul 20 '05 #6
On Tue, 29 Jul 2003 20:03:16 GMT, Jim Ley <ji*@jibbering.com> wrote:
On Tue, 29 Jul 2003 10:11:38 -0600, Charles Banas <no****@myplace.net>
wrote:
sorry - to clarify, i'm doing this in Access 97 through the
InternetExplorer "automatin" object. maybe i shouldn't have put
"JavaScript" in the subject....


Automating it with JS or VBA or whatever, the Object Model is the
same, and snufkin shows how to override window methods (not
window.alert specifically) but others to achieve what you want, making
them non-interactive, if you look at Snork an even older piece of code
knocking about on my site, I think you'll even see alert being
over-ridden.

Doing what you want is simple automating IE from JS, I'm sure it will
be simple from VBA too, but VBA is just a muppet language.

Jim.


i'll look it over more closely, then.

thanks

--
Charles Banas
Jul 20 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Sue | last post by:
After finishing up my first quarter JavaScript on 12/12/03, I decided to improve character checking on my project. In my project I only had to do very basic validation. Therefore, I only had one...
8
by: Prometheus Research | last post by:
http://newyork.craigslist.org/eng/34043771.html We need a JavaScript component which will auto-submit a form after a set period has elapsed. The component must display a counter that dynamically...
14
by: tshad | last post by:
I posted this on the asp.net group, also. I wasn't sure whether this was an asp.net problem or a javascript problem. I have a page that was originally created from a program I found on the net...
4
by: Ike | last post by:
Oh I must be missing somethign so simple and stupid. I need to do a submit() via an href, which I do (succesfully) in JavaScript in many other pages with <a...
10
by: ljlolel | last post by:
So.. I have a form that submits to an ASP.net site made in C-sharp. The ASP site is not mine, i do not have the server side code. When I submit from my form by pressing the Submit button, I get...
12
by: googlegroups | last post by:
Hi, I'm making a javascript program for rolling dice for a roleplaying game that's played in a forum. The die roll gets generated, gets stored as text in a hidden form field, and then gets written...
27
by: Chris | last post by:
Hi, I have a form for uploading documents and inserting the data into a mysql db. I would like to validate the form. I have tried a couple of Javascript form validation functions, but it...
3
Plater
by: Plater | last post by:
I am having a spot of trouble with a little situation. I want to make the submit invisible on a submit so that the user cannot keep clicking on it while the server is receiving the file transfer....
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.