CancelImage Upload

How to call upon a JavaScript function via a HTML Button

Previously I have discussed how a JavaScript function can be called upon via an anchor tag. The same principles of course are also applicable to HTML buttons, images, and other HTML elements. All that is required, and the main difference from calling upon a function via the anchor tag, is that instead of calling upon the function via href it is done via the onClick command:

<input type="button" onclick="javascript:alert('hello world');" value="Click Here">

Upon clicking the above defined button an alert message box will appear with the caption "hello world". Of course the alert() could be replace with any other JavaScript code, including calling upon a function.

Login
Want to leave a comment?

No problem. Just enter your email and password below.


register | home | reminder

myDesignTool Networking • www.mydesigntool.cominfo@mydesigntool.com