Passed Variable not working with my function - Javascript
<p>I've got  text entry box and a countdown on the same page. I want to take the time from the box and enter it into the counter. I've got a variable back from the text box "setTime". I wanted to put that directly into my timeSplit function (to convert the time into seconds) but when I do I get an error that "time.split is not a function". What am I doing wrong here?</p>

<p>When I have a static variable enter the function (e.g. time = "12:12:12") everything works perfectly. - except its not using the right time</p>

<p>When I run the pop up alert on setTime before the timeSplit function I see my time like this "12:12:12" so its coming from the counter without a problem and I don't get a NaN error</p>

<p>Why would a time variable work when its static but not when its passed</p>

<p>I tried converting the setTime to a string but that just lead to NaN errors even when I tried to convert the sec variable back to an int.</p>

<p>I think this is the relevant code let me know if you need more.</p>

<pre><code>var setTime = 0;
var $fromTime = $("#formEntry");

$("#setTime").off("click").on("click", function(){
  setTime = $fromTime.val();
});

function timeSplit(){
  //time = "12:12:12";
  tt = time.split(":");
  sec = tt[0]*3600+tt[1]*60+tt[2]*1;
  return sec;
}

var time = setTime;
//var time = "12:12:12";
var sec = timeSplit(time);
</code></pre>
