Hello.
Got another one for you folks. I'm working on this problem that wants me to
1. Prompt for name
2. Use pop-up box with name
3. Display current date on page in format "October 30, 2000."
4. Display last modified date of doc.
Here is my attempt. What a headache :-(
<html><head><title>Problem14</title>
<style type="text/css">
#greeting{position:absolute; left;50px; top:185px;}
#today {position:absolute; left:50px; top:200px;}
</style>
<script type="text/javascript">
function setCookie(){
var today = newDate();
var the_month = today.getMonth()+1;
var the_day = today.getDate;
var the_year = today.getYear();
var mth_list = newArray();
mth_list[0]="";
mth_list[1]=January;
mth_list[2]=February;
mth_list[3]=March;
mth_list[4]=April;
mth_list[5]=May;
mth_list[6]=June;
mth_list[7]=July;
mth_list[8]=August;
mth_list[9]=September;
mth_list[10]=October;
mth_list[11]=November;
mth_list[12]=December;
var alpha_mth = mth_list[the_month];
var the_fixed_year=Y2K(the_year);// separate function
var the_string="Today's date is "+alpha_mth+" "+the_day+","+the_fixed_year;
var condensed_date = alpha_mth+" "+the_day+","+the_fixed_year;
var the_div=document.getElementById("today");
the_div.innerHTML = the_string;
var the_time = today.getTime();
var the_secs = toSt(the_time%60); // toSt is a separate function
var the_time = Math.floor(the_time/60);
var the_mins = toSt(the_time%60);
var the_time = Math.floor(the_time/60);
var the_hours = toSt(the_time%24);
var the_time_string = the_hours+":"+the_mins+":"+the_secs;
var the_cookie = "day="+escape(condensed_date)/"time="+escape(the_time_string)
;
document.cookie = the_cookie;
var cookie_info = newArray();
readCookie(cookie_info);
}
function toSt(n) {
var s=""
if (n<10) s+="0"
return s+n.toString();
}
function Y2K(the_date)
{
if (the_date < 1000)
{
the_date = the_date+1900;
}
return the_date;
}
function readCookie(the_info)
{
if(document.cookie)
{
var the_cookie = document.cookie;
var the_cookie = unescape(the_cookie);
var broken_cookie = the_cookie.split("/");
for (var i=0; i<broken_cookie.length; i++)
{
var split_again = broken_cookie[i].split("=");
var the_values = split_again[1];
var the_property = split_again[0];
the_info[the_property] = the_values;
}
}
}
</script></head>
<body onLoad = setCookie(); window.status="Always remember...patience,
persistance, resilience";>
<script type="text/javascript">
var the_name=prompt("what's your name","");
alert ("Welcome, "+the_name+" to my page.");
document.write("The last time you were here or the page was updated was on "
+
cookie_info["day"]+" at "+ cookie_info["time"]);
</script>
<div id="greeting"></div>
<div id="today"></div>
</body>
</html>
And I get a blank screen after all of this.
--
Message posted via WebmasterKB.com
http://www.webmasterkb.com/Uwe/Forum...cript/200808/1