Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I imported the javascript file in the head like this :

<script type="text/javascript" src="js/ISO_TR_230-9.js"></script>

That file contains a function calc1 which is set up like this :

function calc1() {}

I am calling calc1 from a button that is set up like this :

<button type="button" onclick="calc1()">Calculate</button>

Upon clicking the button I receive the error calc1 is not defined. Is there anything that could be happening where this occurs?

share|improve this question

closed as too localized by pst, j08691, bfavaretto, Andrey Shchekin, Chris Aug 2 '12 at 5:59

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

1  
Is the javascript include actually available with the relative path given? If you are using browser development tools, are you actually getting a HTML 200 response fro the request for that file? –  Mike Brant Aug 1 '12 at 20:47
    
Have you checked the developer console to make sure the script is being loaded? –  j08691 Aug 1 '12 at 20:47
    
The external resources is 1) not loaded/available 2) does not define calc1 or 3) contains errors that prevents #1 or #2. Checking the resource network traffic (e.g. with Firebug or Developer Tools) should help .. –  user166390 Aug 1 '12 at 20:47
    
The javascript file is being loaded, and does define calc1, as the first function. If it is first then why would there be previous errors? –  Jonathan Wrona Aug 1 '12 at 20:49
    
@JonathanWrona Check the actual response in Firebug or Developer Tools: e.g. was/is it cached? Later JS can affect the first function (re-assignment) and very humongously wrong syntax constructs could play games with the parsing. –  user166390 Aug 1 '12 at 20:50

1 Answer 1

<button type="button" onclick="calc1()">Calculate</button>

That style of setting the events is old. I think hast been created when you call it.

so try put the handler in the JS-file. and, window.onload() or Smthn from Jq.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.