I an new to javascript and that might be my problem but I would like to have some one help me fix it. Here's my function code
Quote:
function janCountDown()
{
var today = new Date()
var dayofweek = today.toLocalDateString()
dayLocate = dayofweek.indexOf(" ")
weekDay = dayofweek.substring(0, dayLocate)
newDay = dayofweek.substring(dayLocate)
dateLocate = newDay.indexOf(",")
monthLocate = newDay.substring(0, dateLocate+1)
yearLocate = dayofweek.indexOf(", 2")
year = dayofweek.substr(yearLocate+2, 4)
var janNewYear = new Date("January 1, 2013")
var daysToGo = janNewYear.getTime()-today.getTime()
var daysToJanNewYear = Math.ceil(daysToGo/(1000*60*60*24))
document.getElementById("Jan").innerHTML=t;
displayCountDown.innerHTML = "<p>Today is "+weekDay+" "+monthDate+" "+year+". We have "+daysToJanNewYear+" days until New Years Day.</p>"
}
t is not defined anywhere, nor is displayCountDown or monthDate.
Each of your (presumably local) variables should be preceded with var and JS statements end with semi-colons ;
__________________
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
Validate your HTML and CSS
Ok so I have fixed (or I think its fixed) but it still is not showing up it acks like its going to but then nothing happens.
Quote:
function janCountDown()
{
var today = new Date();
var dayofweek = today.toLocalDateString();
dayLocate = dayofweek.indexOf(" ");
weekDay = dayofweek.substring(0, dayLocate);
newDay = dayofweek.substring(dayLocate);
dateLocate = newDay.indexOf(",");
monthLocate = newDay.substring(0, dateLocate+1);
yearLocate = dayofweek.indexOf(", 2");
year = dayofweek.substr(yearLocate+2, 4);
var janNewYear = new Date("January 1, 2013");
var daysToGo = janNewYear.getTime()-today.getTime();
var daysToJanNewYear = Math.ceil(daysToGo/(1000*60*60*24));
document.getElementById("Jan").innerHTML="<p>Today is "+weekDay+" "+monthDate+" "+year+". We have "+daysToJanNewYear+" days to go.</p>";
}
What does the error console say? That's the best place to start when a script doesn't work properly. If that doesn't help then the debugger is the next place to start looking - you can see allt he values at the point it stopped there. (If you are testing on Firefox you will need to install a debugger extension if you haven't already - all the other browsers have one built in).
You still don't have a variable named monthDate, which appears in the final string statement.
As felgall advises, you need to make use of a browser's console.
__________________
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
Validate your HTML and CSS
That is a strange way to extract the components of a Javascript date object.
I assumed the OP is just experimenting..
__________________
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
Validate your HTML and CSS
What does the error console say? That's the best place to start when a script doesn't work properly. If that doesn't help then the debugger is the next place to start looking - you can see allt he values at the point it stopped there. (If you are testing on Firefox you will need to install a debugger extension if you haven't already - all the other browsers have one built in).
How would I get to the debugger in IE. Because I don't know how to get to the console.
__________________
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
Validate your HTML and CSS