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