The14thGOD Posted March 24, 2010 Share Posted March 24, 2010 I'm a noob when it comes to JS, but every example I've seen for a looping function looks the same but when I do it I get 'startTime is not defined'. here's the function: (it's inside a jquery ready function, so it doesn't start till everything is loaded) var colon = 0; function startTime(){ var today = new Date(); var hours = today.getHours(); var mins = today.getMinutes(); var monthdate = today.getDate(); var ampm = 'am'; if(hours>11){ ampm = 'pm'; } if(mins<10){ mins = '0'+mins; } $('#the_date').text(monthdate); $('#the_time_h').text(hours); $('#the_time_m').text(mins); $('#the_time_ampm').text(ampm); if(colon == 0){ $('#the_time_colon').css('visibility','hidden'); colon = 1; }else{ $('#the_time_colon').css('visibility','visible'); colon = 0; } //month var month = today.getMonth(); var months = new Array(13); months[0] = "January"; months[1] = "February"; months[2] = "March"; months[3] = "April"; months[4] = "May"; months[5] = "June"; months[6] = "July"; months[7] = "August"; months[8] = "September"; months[9] = "October"; months[10] = "November"; months[11] = "December"; $('#month p').text(months[month]); $('#month p').addClass(months[month].toLowerCase()); timer=setTimeout("startTime()",500); } startTime(); Thx for any and all help. Justin Link to comment https://forums.phpfreaks.com/topic/196379-looping-function/ Share on other sites More sharing options...
KevinM1 Posted March 24, 2010 Share Posted March 24, 2010 What, exactly, is inside of jQuery's $(document).ready() function? I ask because you don't want to put your function definition there. Only it's invocation. Link to comment https://forums.phpfreaks.com/topic/196379-looping-function/#findComment-1031098 Share on other sites More sharing options...
The14thGOD Posted March 24, 2010 Author Share Posted March 24, 2010 Um, a lot of ajax calls and form checking type things. I had another function in there so though it was ok. I just put it outside, along with the colon variable, and it appears to be working. Thanks, justin Link to comment https://forums.phpfreaks.com/topic/196379-looping-function/#findComment-1031110 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.