javascript - One script modifying the other's output? -
i'm having difficulties making these 2 scripts operate together.
the first script changes numbers 0-9 respective image, while second displays count-up occurring @ set interval/increment. don't know why (on account of noobness) these 2 don't along.
this how i've been trying run these together:
<script type=”text/javascript”> <!– counterimages(input); //–></script> <div id="counter"></div>
here's .js file:
function counterimages(input) { var output = "" (var = 0; < input.length; i++) { var chr = input.substring(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; } } var start_date = new date("october 21, 2012 22:30:00"); // put in 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 start date var count = 0; jquery(document).ready(function($) { var msinterval = interval * 1000; var = 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); });
Comments
Post a Comment