Title: JavaScript calculator and form
Last modified: August 22, 2016

---

# JavaScript calculator and form

 *  [baldonius](https://wordpress.org/support/users/baldonius/)
 * (@baldonius)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/javascript-calculator-and-form/)
 * I’ve made a simple JavaScript calculator where the user selects two variables
   in a table, which are assigned values dependent on their choice, and then click
   an OnClick button tag below the table giving them an answer below the button.
 * ‘calc.js’ is the JavaScript file that does the calculation. Inside calc.js the
   main function `calculate()` is called by the button on the page that user sees:`
   <button onclick="calculate()">Calculate</button>`.
 * The JavaScript works, I currently have it in a standalone html file, which I’ve
   included on a WordPress page using an iframe. Fine for now for users who are 
   none the wiser but I’d rather have the calculator actually in my WordPress site.
 * So I put this in the header.php file:
 *     ```
       <?php if (is_page(244)) {
       echo '<script type="text/javascript" src="/calc.js"></script>';
       } ?>
       ```
   
 * And then I put the table code into the editor for the page, and the table itself
   shows up fine. But when I enter my two variables and click the button, nothing
   happens.
 * So can any of you guys help me out?

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

 *  [Andrew Nevins](https://wordpress.org/support/users/anevins/)
 * (@anevins)
 * WCLDN 2018 Contributor | Volunteer support
 * [11 years, 9 months ago](https://wordpress.org/support/topic/javascript-calculator-and-form/#post-5245258)
 * You can use the same debugging techniques from your standalone application as
   you can in WordPress. Use your browser developer tool to access the console log.
   Look at the information there to decipher what’s going on. Just looking at the
   header.php code right now I can tell you that the URL to the file is probably
   wrong.
 *  Thread Starter [baldonius](https://wordpress.org/support/users/baldonius/)
 * (@baldonius)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/javascript-calculator-and-form/#post-5245283)
 * The url to the file is correct. I have also tried `src="calc.js"` and the full
   path to the file. The Chrome developer tool gives no particular notifications
   about the JavaScript.
 *  [Andrew Nevins](https://wordpress.org/support/users/anevins/)
 * (@anevins)
 * WCLDN 2018 Contributor | Volunteer support
 * [11 years, 9 months ago](https://wordpress.org/support/topic/javascript-calculator-and-form/#post-5245337)
 * Hopefully you can link the page with the issue.

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

The topic ‘JavaScript calculator and form’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 2 participants
 * Last reply from: [Andrew Nevins](https://wordpress.org/support/users/anevins/)
 * Last activity: [11 years, 9 months ago](https://wordpress.org/support/topic/javascript-calculator-and-form/#post-5245337)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
