Title: Javascript function &#8211; how to call it in WordPress
Last modified: August 19, 2016

---

# Javascript function – how to call it in WordPress

 *  [shusheme](https://wordpress.org/support/users/shusheme/)
 * (@shusheme)
 * [17 years, 1 month ago](https://wordpress.org/support/topic/javascript-function-how-to-call-it-in-wordpress/)
 * I am migrating a static site (which is now offline because I have made the WordPress
   site the current one) and it has a few calculators on some of the pages. When
   I say a few, there are 7-8 of them, which I have added to one file (scripts.js).
   Each of the calculators is on a separate page, with their own functions to enable
   them to work (which they did before, but I dont know how to make them work now).
   These are simple fitness calculators, for different things.
 * I uploaded the scripts.js file in my scripts folder under my theme folder and
   have tried to call that from the header file, but to no avail!
 * I have also tried following the instructions on this post [http://wordpress.org/support/topic/147154?replies=4](http://wordpress.org/support/topic/147154?replies=4),
   but I dont really understand how to do it, as I dont have a ‘single.php” file
   with my them. I have also read the WordPress Codex documentation on Javascript,
   which I followed, but it didnt solve my problem either…
 * I am using my site as a CMS, so using pages, as opposed to posts.
 * I am sure it must be something simple that I am missing, but I dont know what
   it is and I am getting a bit frustrated with it all.
 * Is there anyone who can possibly give me advice on what to do with the javascript
   to make it work?
 * Thanks

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [shane-g](https://wordpress.org/support/users/shane-g/)
 * (@shane-g)
 * [17 years, 1 month ago](https://wordpress.org/support/topic/javascript-function-how-to-call-it-in-wordpress/#post-1046591)
 * Hi,
 * Please refer this link for details:
 * [http://codex.wordpress.org/Using_Javascript](http://codex.wordpress.org/Using_Javascript)
 * Thanks,
 * Shane G.
 *  Thread Starter [shusheme](https://wordpress.org/support/users/shusheme/)
 * (@shusheme)
 * [17 years, 1 month ago](https://wordpress.org/support/topic/javascript-function-how-to-call-it-in-wordpress/#post-1046704)
 * Hi Shane
 * Thanks for providing the link, but I have tried to follow the Codex according
   to the page you showed above, but I must be missing something, as it still does
   not work and I have no idea why.
 * For example, in my page, I have the script to calculate Target Heart Rate. It
   has two inputs (height and weight) and when the button is clicked, it outputs
   the target heart rate. The following is the JS function when the users hits the
   button to calculate:
 * > <input id=”Button1″ onclick=”calcIt()” name=”Button1″ type=”button” value=”
   > Calculate” /></td>
 * I have then added the script which runs the calculator in a file called scripts.
   js in my theme folder and then added the appropriate code to the header file.
 * I just saw this other post – is this what I should do for my functions? [http://wordpress.org/support/topic/248327?replies=3](http://wordpress.org/support/topic/248327?replies=3)
 * Maybe I will try it…

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Javascript function – how to call it in WordPress’ is closed to new replies.

## Tags

 * [javascript](https://wordpress.org/support/topic-tag/javascript/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [shusheme](https://wordpress.org/support/users/shusheme/)
 * Last activity: [17 years, 1 month ago](https://wordpress.org/support/topic/javascript-function-how-to-call-it-in-wordpress/#post-1046704)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
