JavaScript, Variables, and Cookies
I have a page that is attempting to determine your bandwidth to my site. I have the java functions in place to do so . But when I try and put the resulting value in a cookie it continually says "undefined" in the cookie where the value should be. I need to pass this variable to the next page to display it. Here is my code, someone tell me what I am doing wrong. Keep in mind I don't have much experience in Java.
There are no <> because for some reason anything between them won't post here.
Code:
script language = "JavaScript"
cookie_name = "Results";
var kbytes;
var kbits;
function RightNow() {
time = new Date();
return time.getTime();
}
function CalculateSpeed(timeStart) {
timeEnd = RightNow();
timeElapsed = (timeEnd - time Start)/1000;
kbytes = 200/timeElapsed;
kbits = kbytes * 1024 * 8;
}
function puCookie() {
if (document.cookie !=document.cookie)
{index = document.cookie.index0f(cookie_name);}
else
{index = -1;}
if (index == -1)
{
TestResults = kbits
document.cookie=cookie_name + "=" + TestResults + "; expires=Monday, 04-Apr-2010 05:00:00 GMT";
}
}
/script
/head
body
script language="JavaScript"
timeStart = RightNow();
/script
img src="200.jpg" width="20" onload=CalculateSpeed(timeStart);"
script language="JavaScript"
putCookie()
nextpage='results.asp'
document.locations.href=nextpage;
/script
/body
/html