Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #33570
| Path | csiph.com!aioe.org!.POSTED!not-for-mail |
|---|---|
| From | parmenides <xparmenides@yahoo.com> |
| Newsgroups | comp.lang.javascript |
| Subject | How to call another function? |
| Date | Mon, 3 Jul 2017 14:37:04 +0800 |
| Organization | Aioe.org NNTP Server |
| Lines | 36 |
| Message-ID | <ojcomg$16ad$1@gioia.aioe.org> (permalink) |
| NNTP-Posting-Host | XvVSx2sNhFLRPV14DHpQtA.user.gioia.aioe.org |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=gbk; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Complaints-To | abuse@aioe.org |
| User-Agent | Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 |
| X-Mozilla-News-Host | news://nntp.aioe.org:119 |
| X-Notice | Filtered by postfilter v. 0.8.2 |
| Xref | csiph.com comp.lang.javascript:33570 |
Show key headers only | View raw
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