ballhogjoni Posted March 5, 2008 Share Posted March 5, 2008 This is the line of code that contains the output from the function below: <div id="colorize" class="timeClass">RSVP WITHIN <span id="theTime"></span></div> This is the line that is "undefined" in the below function: if (document.getElementById) { theTime.innerHTML = time; } In firefox I get this error: theTime is not defined. In IE this works fine function countDown() { sec--; if (sec == -01) { sec = 59; min = min - 1; } else { min = min; } if (sec<=9) { sec = "0" + sec; } time = (min<=9 ? "0" + min : min) + ":" + sec; if (document.getElementById) { theTime.innerHTML = time; } SD=window.setTimeout("countDown();", 1000); if (min == '00' && sec == '00') { sec = "00"; window.clearTimeout(SD); alert("Your Time Has Expired, Please Close This Box For More Time."); } } In firefox I get this error but works just fine, In IE this doesn't work: document.getElementById("colorize") has no properties for this code. var c = new Array("#FFFF33", "#FFFF00", "#FFFF33", "#FFFF55", "#BDB8BC", "#FFFF55", "#FFFF33", "#FFFF00", "#FFFF33", "#FFFF55", "#BDB8BC", "#FFFF55", "#FFFF33", "#FFFF00", "#FFFF33", "#FFFF55", "#BDB8BC", "#FFFF55", "#FFFF33", "#FFFF00", "#FFFF33", "#FFFF55","#BDB8BC", "#FFFF55", "#FFFF33", "#FFFF00", "#FFFF33", "#FFFF55", "#BDB8BC", "#FFFF55", "#FFFF33", "#FFFF00", "#FFFF33", "#FFFF55", "#BDB8BC", "#FFFF55", "#FFFF33", "#FFFF00", "#FFFF33", "#FFFF55", "#BDB8BC", "#FFFF55", "#FFFF33", "#FFFF00", "#FFFF33", "#FFFF55", "#BDB8BC", "#FFFF55", "#FFFF33", "#FFFF00", "#FFFF33", "#FFFF55", "#BDB8BC", "#FFFF55", "#FFFF33", "#FFFF00", "#FFFF33", "#FFFF55", "#BDB8BC", "#FFFF55", "#FFFF33", "#FFFF00", "#FFFF33", "#FFFF55"); x = 0; function bg_eff() { var col_val = c[x]; document.getElementById("colorize").style.background = col_val; x++; if (x == 64) { document.getElementById("colorize").style.background="#BDB8BC"; clearInterval(change_bg); } } change_bg = setInterval("bg_eff()", 200); Quote Link to comment Share on other sites More sharing options...
haku Posted March 6, 2008 Share Posted March 6, 2008 For the first function, your problem is easy - theTime hasn't been defined. It says so right in the error! You are trying to use something called theTime, but you haven't told javascript what that is anywhere, so it cant do anything with it. The second one is a little different. I'm not sure why its not working, but the way you are trying to do it isn't the most ideal method anyways. You create a CSS class that has the properties that you want, and then rather than changing the style, change the classname. With firefox you change the classname using object.setAttribute("class","class_name_goes_here") and with IE you set it like this: object.className="class_name_goes_here" Quote Link to comment Share on other sites More sharing options...
ballhogjoni Posted March 6, 2008 Author Share Posted March 6, 2008 For the first function, your problem is easy - theTime hasn't been defined. It says so right in the error! You are trying to use something called theTime, but you haven't told javascript what that is anywhere, so it cant do anything with it. How would I define theTime. I am a newb with javascript. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.