Title: Need help with this javascript code for this calculator!
Last modified: August 22, 2016

---

# Need help with this javascript code for this calculator!

 *  [mkpdesigns](https://wordpress.org/support/users/mkpdesigns/)
 * (@mkpdesigns)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/need-help-with-this-javascript-code-for-this-calculator/)
 * Hi there! Thank you very much for viewing!
 * I am working on trying to add these calculators over to this new site that I 
   built with WordPress, but I am having no luck! The HTML and CSS work, but I do
   not think I am adding the Javascript, as the Calculate and Clear buttons do not
   function, here at:
    [http://www.dbhirdotrucking.com/#calculators](http://www.dbhirdotrucking.com/#calculators)
 * I am completely new with JS in WP, but after researching, I added this line code
   to the themes header.php and calculators-page.php (the template I used for the
   page):
 * `<script type="text/javascript" src="<?php bloginfo('template_url'); ?>/js/calc.
   js"></script>`
 * Which references to the calc.js, which is:
 *     ```
       <script type="text/javascript">
       	function calculate()
       	{
       		var length =$('.length_ajax').val();
       		var width =$('.width_ajax').val();
       		var depth =$('.depth_ajax').val();
       		var tot = length*width*depth/324;
       		var tot = tot.toFixed(2);
       		$('.totalcal').val(tot);
   
       		var sf = length*width;
       		var sf = sf.toFixed(2);
       		$('.squarefeet').val(sf);
       	}
       	function clearall()
       	{
       		$('.length_ajax').val('');
       		$('.width_ajax').val('');
       		$('.depth_ajax').val('');
       		$('.totalcal').val('');
       		$('.squarefeet').val('');
       	}
       	</script>
       ```
   
 * I have spent days trying to figure this out on my own, but I really need help
   please! Any attempts to help are GREATLY appreciated!
 * Thanks for reading!!!
    Mike

Viewing 1 replies (of 1 total)

 *  [bernbe01](https://wordpress.org/support/users/bernbe01/)
 * (@bernbe01)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/need-help-with-this-javascript-code-for-this-calculator/#post-5825401)
 * hey there
 * i see on that page that there is a file you are including, calc.js located here
 * [http://www.dbhirdotrucking.com/wp-content/themes/jarvis_wp/js/calc.js](http://www.dbhirdotrucking.com/wp-content/themes/jarvis_wp/js/calc.js)
 * it currently has open and close tags for the script, which are creating a broken
   syntax error in Chrome’s console (press F12, flip to console if you’re in Chrome)
   for me
 * For example, this valid file does not include <script></script> tags
 * want to edit your calc.js file and remove this line:
 * `<script type="text/javascript">`
 * and this line:
 * `</script>`
 * and let me know and we can retest together?

Viewing 1 replies (of 1 total)

The topic ‘Need help with this javascript code for this calculator!’ is closed to
new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [bernbe01](https://wordpress.org/support/users/bernbe01/)
 * Last activity: [11 years, 2 months ago](https://wordpress.org/support/topic/need-help-with-this-javascript-code-for-this-calculator/#post-5825401)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
