Quote:
Originally Posted by felgall
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);
};
|
Stephen,
Thank you for the script. Should this code be placed inside or outside the brackets that describe my js function a()? Actually, I tried both ways but it does not seem to work. I put the script for my function a() along with your code in an external .js file and changed html for the button exactly as wrote, but I am not proficient with js so maybe I am missing a simple thing. And I presume of course if all v1, v2, etc are described within the same function a(), I can put there
a(document.form.v1.value);
a(document.form.v2.value); ?