Hi I want to take all the javascript code in my html file and put it into external .js file. Currently the javascript code is inside the html and when a button is pushed(onclick) it works. When I copy and paste the javascript and put into a test.js file to call it within the head of the html like this <script src='test.js' type='text/javascript' /></script> and then hit button ( <input type="button" onclick="setAlarm()" value="Set Alarm" /> ) FireBug says setAlarm is not defined. Within the test.js is function setAlarm() . Again I just copy/pasted this exact function from the html where it was working before but the button code was <input type="button" value="Set Alarm" onclick="javascript: setAlarm();" />. So works within html but when called from test.js it is not. Any idea why this is and what I might be missing? Thanks
working for me..., when I try this script index.html <html> <head> </head> <script src='test.js' type='text/javascript' /></script> <body> <input type="button" onclick="javascript: setAlarm();" value="10" /> </body> </html> Code (markup): test.js function setAlarm() { alert('hai'); } Code (markup): please check again your file... (on same folder or not)