• 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

    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)
  • 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

    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.