I am working on making changes to an existing page
It would then be a good idea to consider posting the URL.
(as evident from previous posts)
I think there are about a million previous posts. Don't expect us to
trace back what you might have posted "recently".
that has multiple methods that should be executed
"onsubmit".
That does not quite parse. Well, it parses, but the meaning remains
obscure. I guess you mean that the page has a form with an onsubmit
attribute, the value of which contains several function calls, like
onsubmit="foo(); bar(); zap(1,2,3)". Whether the functions are methods
is immaterial here.
I dn't want to break those.
A good idea. Keep your code clean, don't mess around with global
variables unless you really have to.
So if there are, say, five
JavaScript functions in one or more<script> </script> blocks, are
these executed in the order that the onsubmit invocations occur on the
page?
Functions are not executed at all, unless they are called. When called,
they are executed in the order of the calls (invocations). The onsubmit
attributes as such do not cause any function calls. They are event
handlers, so the order depends on what the user does. But when a form is
being submitted, then its onsubmit attribute is executed. If it is
onsubmit="foo(); bar(); zap(1,2,3)", then the functions are called in
that order.
If one of these fails, does that make the others fail?
It depends on the meaning of "fails". Just doing something else than it
was meant to be does not affect others. But if an exception is thrown
and the exception is not handled, then the rest of script execution is
skipped. So if you prepend a function call of your own, say
onsubmit="zip(); foo(); bar(); zap(1,2,3)"
then the other functions won't be called if your function, say, tries to
use a.b when the value of a is undefined.
A fairly brutal but effective way to avoid such problems is to use the
try statement so that exceptions thrown in your function will just be
discarded:
onsubmit="try { zip() } catch(e) {}; foo(); bar(); zap();"
In reality, you would of course use the try statement inside your
function and make it at least report the errors:
function zip() {
try {
// do whatever zips do here
} catch(e) {
alert('Error (code ' + e.name + '): ' + e.message); }}
I am
guessing that since the function should return true or false that if
it returns false, nothing else is executed.
No, the function return value is just ignored (discarded), unless the
program code does something with it.