Jump to content

looping function


The14thGOD

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.