how to make event in html link to function in javascript?

<input type = "button" value = "Calculate!" onclick = "GradeCalculator()" >

which is a reference to my function my

javascript file projectJS

<script type = "text/javascript" src = "projectJS.js"></script>

what do i need to put after onclick to have it access the funciton in my javascript file

Update:

I found out why it was erroring

2 Answers

Relevance
  • Chris
    Lv 7
    2 years ago
    Favorite Answer

    If you have

    function GradeCalculator() {

    ...

    }

    in your JS file, it'll already work.

  • kathys
    Lv 4
    2 years ago

    The argument is that your html content should remain focused solely on content, not on presentation or behavior. The typical path these days is to use a javascript library (eg. jquery) and create an event handler using that library. It would look something like: $('a').click( function(e) {e.preventDefault(); ...

Still have questions? Get your answers by asking now.