由于在你的 while 循环,导致页面里出现了多个 id="ff" 的对象,所以会提示缺少对象,你可以用:
<td onmousemove="getCourseData(document.getElementById(this));">
用这样方法直接把 TD 这个对象作为参数传到你的处理函数里。当然你还是坚持使用 id 的话可以:
<td id="ff<?=$i+1?>" onmousemove="getCourseData(document.getElementById(this.id));">
<td onmousemove="getCourseData(document.getElementById(this));">
用这样方法直接把 TD 这个对象作为参数传到你的处理函数里。当然你还是坚持使用 id 的话可以:
<td id="ff<?=$i+1?>" onmousemove="getCourseData(document.getElementById(this.id));">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script type="text/javascript" src="ajax/ajax.js"></script>
<link href="shop/css.css" rel="stylesheet" type="text/css" />
</head><body>
<form name="form1" method="post">
<table width="509" height="66" border="1" align="center" class="table">
<tr >
<td width="69" height="26" align="center">编号</td>
<td width="103">商品名称</td>
<td width="313">商品价格</td>
</tr>
<tr>
<td height="30" align="center">1</td>
<td id="ff1" onmouseover="getCourseData(document.getElementById(this));">
aa<div id="pic"></div></td>
<td>250.00</td>
</tr>
<tr>
<td height="30" align="center">2</td>
<td id="ff2" onmouseover="getCourseData(document.getElementById(this));">
<!-- 说还缺少对象 -->
bb<div id="pic"></div></td>
<td>120.00</td>
</tr>
</table>
</form>
</body>
</html>
说还缺少对象
或者
<td id="ff <?=$i+1?>" onmousemove="getCourseData(document.getElementById(this.id));">
include("shop/coon.php");
$mydb = new DB();
$mydb->Connect();
$sql ="select * from products";
$query =mssql_query($sql);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script type="text/javascript" src="ajax/ajax.js"></script>
<link href="shop/css.css" rel="stylesheet" type="text/css" />
</head><body>
<form name="form1" method="post">
<table width="509" height="66" border="1" align="center" class="table">
<tr >
<td width="69" height="26" align="center">编号</td>
<td width="103">商品名称</td>
<td width="313">商品价格</td>
</tr>
<?
$i =0;
while($list =mssql_fetch_array($query)){
?>
<tr>
<td height="30" align="center"><?=$i+1?></td>
<td id="ff<?=$i+1?>" onmouseover="getCourseData(document.getElementById(this.id));">
<?=$list['pro_name']?><div id="pic"></div></td>
<td><?=$list['pro_price']?></td>
</tr>
<?
$i++;
}
?>
</table>
</form>
</body>
</html>
改了后还是不行 还说缺少对象 <td id="ff<?=$i+1?>" onmouseover="getCourseData(document.getElementById(this.id));">