| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 518 人关注过本帖
标题:事件处理应用实例怎么会没有对象??
只看楼主 加入收藏
拒绝飞翔的燕
Rank: 1
来 自:郑州
等 级:新手上路
帖 子:5
专家分:0
注 册:2009-11-11
结帖率:50%
收藏
 问题点数:0 回复次数:1 
事件处理应用实例怎么会没有对象??
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.
<html xmlns="http://www.
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>商品评级</title>
<script language="javascript" type="text/javascript">
function $(id){ return document.getElementById(id);}
if(window.ActiveXObject){
var preload0= new Image();
preload0.src="a_23.jpg";
var preload1= new Image();
preload1.src="a_14.jpg";
}
var score=3;
function setScore(score){
for( var i=0;i<=5;i++){var img=$("img"+String(i));
img.src=(i<=score)?"a_23.jpg":"a_14.jpg";}
function commitScore(s){score=s;}
function resetScore(){setScore(score);}

}
</script>
</head>

<body>
<div id="vote">
星级:
<img src="a_23.jpg" id="img0" height="20px" width="20px"onmouseover="setScore(0)" onclick="commitScore(0)"onmouseout="resetScore()" alt="0"/>
<img src="a_23.jpg" id="img1"  height="20px" width="20px"onmouseover="setScore(1)" onclick="commitScore(1)"onmouseout="resetScore()" alt="1"/>
<img src="a_23.jpg" id="img2" height="20px" width="20px"onmouseover="setScore(2)" onclick="commitScore(2)"onmouseout="resetScore()" alt="2"/>
<img src="a_23.jpg" id="img3" height="20px" width="20px"onmouseover="setScore(3)" onclick="commitScore(3)"onmouseout="resetScore()" alt="3"/>
<img src="a_14.jpg" id="img4" height="20px" width="20px"onmouseover="setScore(4)" onclick="commitScore(4)"onmouseout="resetScore()" alt="4"/>
<img src="a_14.jpg" id="img5" height="20px" width="20px"onmouseover="setScore(5)" onclick="commitScore(5)"onmouseout="resetScore()" alt="5"/>
</div>
<div>
<textarea rows="5" cols="25"></textarea>
</div>
<button>提交</button>
</body>
</html>
搜索更多相关主题的帖子: 对象 实例 
2009-11-17 21:16
aspic
Rank: 17Rank: 17Rank: 17Rank: 17Rank: 17
等 级:贵宾
威 望:51
帖 子:2258
专家分:8050
注 册:2008-2-18
收藏
得分:0 
程序代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www. xmlns="http://www. http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>商品评级</title>
<script language="javascript" type="text/javascript">
function $(id) {
    return document.getElementById(id)
}
var score = 3;
function setScore(score) {
    for (var i = 0; i <= 5; i++) {
        var img = $("img" + i);
        img.src = (i <= score) ? "star2.gif": "star1.gif"
    }
}
function commitScore(s) {
    score = s;
    alert('当前评分:' + s)
}
function resetScore() {
    setScore(score)
}
</script>
</head>

<body>
<div id="vote"> 
星级:
<img src="star1.gif" id="img0" height="20px" width="20px" onmouseover="setScore(0)" onclick="commitScore(0)" onmouseout="resetScore()" alt="0"/>
<img src="star1.gif" id="img1"  height="20px" width="20px" onmouseover="setScore(1)" onclick="commitScore(1)" onmouseout="resetScore()" alt="1"/>
<img src="star1.gif" id="img2" height="20px" width="20px" onmouseover="setScore(2)" onclick="commitScore(2)" onmouseout="resetScore()" alt="2"/>
<img src="star1.gif" id="img3" height="20px" width="20px" onmouseover="setScore(3)" onclick="commitScore(3)" onmouseout="resetScore()" alt="3"/>
<img src="star1.gif" id="img4" height="20px" width="20px" onmouseover="setScore(4)" onclick="commitScore(4)" onmouseout="resetScore()" alt="4"/>
<img src="star1.gif" id="img5" height="20px" width="20px" onmouseover="setScore(5)" onclick="commitScore(5)" onmouseout="resetScore()" alt="5"/>
</div>
<div>
<textarea rows="5" cols="25"></textarea>
</div>
<button>提交</button>
</body>
</html>
用到的图
图片附件: 游客没有浏览图片的权限,请 登录注册
图片附件: 游客没有浏览图片的权限,请 登录注册
2009-11-18 09:37
快速回复:事件处理应用实例怎么会没有对象??
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.044263 second(s), 9 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved