Click to See Complete Forum and Search --> : Calling a javascript function
turfbult
Nov 22nd, 2000, 05:58 AM
I have a javascript function on my page call checkout().
How can I call this function from anywhere in my page.
Presently I have it in my input statement like this..
<input type="button" onclick="checkout()" value="submit">
I want to be able to call this function anywhere/anytime in my page.
Thanks
sebs
Nov 22nd, 2000, 07:20 AM
As simple as that :
<script language=javascript>
checkout();
</script>
Something like this:
<SCRIPT LANGUAGE="JavaScript">
function myfunc(){
//-----Do your function----->
}
</SCRIPT>
And then you can call it whereever:
<body onLoad="myfunc()">
<input type="button" onclick="myfunc()" value="submit">
etc.
etc.
da_silvy
Nov 23rd, 2000, 04:40 AM
i think
<input type="button" onclick="javascript:checkout()" value="submit">
also works
Oops. da_silvy, javascript: function() is not needed. I don't believe you need the javascript: part.
And there is an error in my code.
This is incorrect:
<body onLoad="myfunc()">
<input type="button" onclick="myfunc()" value="submit">
This is correct:
<body onLoad="myfunc();">
<input type="button" onclick="myfunc();" value="submit">
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.