My JavaScript not working.iUnsolved!

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
JellyFish
DevNet Resident
Posts: 1361
Joined: Tue Feb 14, 2006 7:18 pm
Location: San Diego, CA

My JavaScript not working.iUnsolved!

Post by JellyFish »

When ever I move my mouse over the image it just says an error in the status bar.

Code: Select all

<?

//set two variables with the value of the database name and table name
$db_name = "";
$table_name = "";

//make a connection to the database
$connection = @mysql_connect("", "", "") or die(msql_error());

//set a variable to select a database I guess
$db = @mysql_select_db($db_name, $connection) or die(mysql_error());


$sql_sel = "SELECT picture, webaddress FROM $table_name ORDER BY picture";
$result = @mysql_query($sql_sel,$connection) or die(mysql_error());

?>
<html>
<head>
<title>Home Page (example)</title>
<SCRIPT LANGUAGE="JavaScript">


//   ##############  SIMPLE  BROWSER SNIFFER
if (document.layers) {navigator.family = "nn4"}
if (document.all) {navigator.family = "ie4"}
if (window.navigator.userAgent.toLowerCase().match("gecko")) {navigator.family = "gecko"}

//  #########  popup text
descarray = new Array(
"This site has some of the greatest scripts around!",
);

overdiv="0";
//  #########  CREATES POP UP BOXES
function popLayer(a){
if(!descarray[a]){descarray[a]="<font color=red>This popup (#"+a+") isn't setup correctly - needs description</font>";}
if (navigator.family == "gecko") {pad="0"; bord="1 bordercolor=black";}
else {pad="1"; bord="0";}
desc = 	  "<table cellspacing=0 cellpadding="+pad+" border="+bord+"  bgcolor=000000><tr><td>\n"
	+"<table cellspacing=0 cellpadding=3 border=0 width=100%><tr><td bgcolor=ffffff><center><font size=-1>"
	+descarray[a]
	+"\n</td></tr></table>\n"
	+"</td></tr></table>";
if(navigator.family =="nn4") {
	document.object1.document.write(desc);
	document.object1.document.close();
	document.object1.left=x+15;
	document.object1.top=y-5;
	}
else if(navigator.family =="ie4"){
	object1.innerHTML=desc;
	object1.style.pixelLeft=x+15;
	object1.style.pixelTop=y-5;
	}
else if(navigator.family =="gecko"){
	document.getElementById("object1").innerHTML=desc;
	document.getElementById("object1").style.left=x+15;
	document.getElementById("object1").style.top=y-5;
	}
}
function hideLayer(){
if (overdiv == "0") {
	if(navigator.family =="nn4") {eval(document.object1.top="-500");}
	else if(navigator.family =="ie4"){object1.innerHTML="";}
	else if(navigator.family =="gecko") {document.getElementById("object1").style.top="-500";}
	}
}

//  ########  TRACKS MOUSE POSITION FOR POPUP PLACEMENT
var isNav = (navigator.appName.indexOf("Netscape") !=-1);
function handlerMM(e){
x = (isNav) ? e.pageX : event.clientX + document.body.scrollLeft;
y = (isNav) ? e.pageY : event.clientY + document.body.scrollTop;
}
if (isNav){document.captureEvents(Event.MOUSEMOVE);}
document.onmousemove = handlerMM;
//  End -->
</head>
<body>
<?
while ($row = mysql_fetch_array($result)) {

	$icon = $row['picture'];
	$webaddress = $row['webaddress'];
	$display_block .= "<a href=\"$webaddress\" onmouseover='popLayer(0)' onmouseout='popLayer()'><img src=\"http:///$icon\" width=20 height=20 border=0></a>";
}
?>
<? echo "$display_block"; ?>
</body>
</html></head>
<body>
<? echo "$display_block"; ?>
</body>
</html>
I don't know javascript just got this off the net but any help is appreciated.

EDITED: This script has been changed and what it does is it doesn't display any pictures. Why is this please help me I'd really really appreciate it.
Last edited by JellyFish on Tue Feb 21, 2006 1:23 am, edited 3 times in total.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Moved to...... Client Side! wee. :?
User avatar
phpScott
DevNet Resident
Posts: 1206
Joined: Wed Oct 09, 2002 6:51 pm
Location: Keele, U.K.

Post by phpScott »

what is the error you are getting?
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

http://www.w3style.co.uk/Javascript_Hig ... /phpdn.php

There's a trailing comma at the end of your array.
I'd also put the "var" keyword infront of descarray to ensure it's globally accessible.

Try using Firefox and open the JavaScript console from the tools menu.... much more useful debug info ;)
User avatar
JellyFish
DevNet Resident
Posts: 1361
Joined: Tue Feb 14, 2006 7:18 pm
Location: San Diego, CA

Post by JellyFish »

What's the var keyword??? 8O Do you mean put var descarray = new Array( ..... ???
Post Reply