Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #33570
| From | parmenides <xparmenides@yahoo.com> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | How to call another function? |
| Date | 2017-07-03 14:37 +0800 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <ojcomg$16ad$1@gioia.aioe.org> (permalink) |
Hi all,
I want to call a function from another funciton in the same js file.
For example, in hello.js two functions are defined as follow:
// hello.js
function hello() {
alert("hello");
}
function submit() {
hello();
return true;
}
Then, the submit() function is called in hello.html:
<--! hello.html -->
<html>
<head>
<title>Document</title>
<script src="hello.js"> </script>
</head>
<body>
<form onsubmit="submit()">
<input type="submit" value="submit" />
</form>
</body>
</html>
But, the message box doesn't pop up as expected. If the onsubmit is
replaced as
onsubmit="hello()"
the message box can pop up. It seeems that a function can not call
another function. Is it correct? How can I deal with the problem? Thanks.
Back to comp.lang.javascript | Previous | Next — Next in thread | Find similar | Unroll thread
How to call another function? parmenides <xparmenides@yahoo.com> - 2017-07-03 14:37 +0800 Re: How to call another function? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-07-03 12:31 +0100 Re: How to call another function? JJ <jj4public@vfemail.net> - 2017-07-04 10:18 +0700
csiph-web