Problem calling on JS function in page
-
Here’s my JS file that has been loaded into Header.php:
// NUMBER TO IMAGE CONVERSION function counterimages(input) { var output = "" for (var i = 0; i < input.length; i++) { var chr = input.substring(i, i + 1) if (chr == '£') { output += '<img border="0" src="img/pound.gif">'; } else if (chr == '.') { output += '<img border="0" src="img/dot.gif">'; } else { output += '<img border="0" src="http://eatiply3.staging.wpengine.com/wp-content/uploads/2013/05/'+(chr+1)+'.png">'; } return output; } // NUMBER COUNTER var START_DATE = new Date("October 21, 2012 22:30:00"); // put in the starting date here var INTERVAL = 1; // refresh interval in seconds var INCREMENT = 769.2; // increase per tick (1/0.0013 ~ 769) var START_VALUE = 35000; // initial value when it's the start date var count = 0; jQuery(document).ready(function($) { var msInterval = INTERVAL * 1000; var now = new Date(); count = parseInt((now - START_DATE)/msInterval) * INCREMENT + START_VALUE; $('#counter').html(count.toFixed(0)); window.setInterval( function(){ count += INCREMENT; $('#counter').html(count.toFixed(0)); }, msInterval); });
What it should do is show a number count-up at the given increment and interval, but substitute the numbers 0-9 for images named respectively.
I am able to make the second script work by plugging in<div id="counter"></div>Meals Provided
into the WordPress page, but for the life of me I can’t get the numbers to convert to images. Here’s what I thought would work: `<script type=”text/javascript” src=”/js/counter.js”></script>
<script type=”text/javascript”>
<!–
counterimages(input);
//–></script>
<div id=”counter”></div>Meals Provided`Thanks!
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Problem calling on JS function in page’ is closed to new replies.