View Single Post
Old 12-12-2012, 09:46 PM   PM User | #2
felgall
Master Coder

 
felgall's Avatar
 
Join Date: Sep 2005
Location: Sydney, Australia
Posts: 5,454
Thanks: 0
Thanked 498 Times in 490 Posts
felgall is a jewel in the roughfelgall is a jewel in the roughfelgall is a jewel in the rough
Best practice would be to move the JavaScript out of the HTML input tag and into a separate JavaScript file. Simply give the button an id and then you can attach as much onclick JavaScript as you need in the JavaScript file rather than in the HTML.

<input value="Calculate" id="calc" type="button">

Code:
document.getElementBiId('calc').onclick = function() {
   a(document.form.v1.value); // or whatever JavaScript you want
   b(document.form.v2.value);
};
or better still use an event listener instead of the event handler so that other independent actions can be attached to the same event.
__________________
Stephen
Learn Modern JavaScript - http://javascriptexample.net/
Helping others to solve their computer problem at http://www.felgall.com/
felgall is offline   Reply With Quote
Users who have thanked felgall for this post:
lzr (12-13-2012)