<div id="GradeVoteArea"> </div>
<div id="GradeVoteScore">请您评分</div>
<script language="JavaScript">
/*
/////////////////////////////////////////////////////////////////////////////////////////////////
//评分系统 BY 王晓斌 2006-11-16
//;函数:
//;;;;;CreateVote(Max,Def);;;;创建平分星星数量 Max为总共多少星星,Def为默认分数
//;;;;;AddContent(sNA)添加平分内容sNA
//;;;;;GradeVoteImage1星星图片一
//;;;;;GradeVoteImage2星星图片二
//////////////////////////////////////////////////////////////////////////////////////////////////
*/
function GradeVote() {
this.VoteMaxStar=1;
this.VoteCounter=1;
this.VoteContent=new Array();
this.GradeVoteImage1="";
this.GradeVoteImage2="";
this.AddContent=function (sNA) {
this.VoteContent["_"+this.VoteCounter]=sNA;
this.VoteCounter++;
}
/*创建评分星星*/
this.CreateVote=function (MaxStar,DefaultStar) {
var i=1,j=1;
var VoteImgHTML="";
this.VoteMaxStar=MaxStar;
for (i=1;i<=MaxStar;i++) {
VoteImgHTML+="<img id="_GradeVoteID"+i+"" src=""+(j<=DefaultStar ? this.GradeVoteImage1 : this.GradeVoteImage2)+"" border="0" onMouseOver="WindowVote.HitVote('"+i+"');" onClick="WindowVote.VoteSubmit('"+i+"');">";
j++;
}
if (document.getElementById("GradeVoteArea")!=null) {
document.getElementById("GradeVoteArea").innerHTML=VoteImgHTML;
}
else {
alert("Object not found!!");
}
}
/* http://bizhi.knowsky.com/ 评分等级内容*/
this.VoteScoreContent=function (sID) {
var VoteContent=this.VoteContent["_"+sID];
if (VoteContent=="undefined" || VoteContent==null) VoteContent="Not defined!!";
return VoteContent;
}
/*鼠标放到星星上*/
this.HitVote=function (sID) {
var i=1;
for (i=1;i<=sID;i++) {
document.getElementById("_GradeVoteID"+i).src=this.GradeVoteImage1;
}
document.getElementById("GradeVoteScore").innerHTML=this.VoteScoreContent(sID);
sID++;
for (i=sID;i<=this.VoteMaxStar;i++) {
document.getElementById("_GradeVoteID"+i).src=this.GradeVoteImage2;
}
}
/*提交评分*/
this.VoteSubmit=function (sID) {
alert("您打了"+sID+"分!");
}
}
var WindowVote = new GradeVote();
WindowVote.GradeVoteImage1="http://img.pc004.com/p/2009-06-22/20090622111549111.gif";
WindowVote.GradeVoteImage2="http://img.pc004.com/p/2009-06-22/20090622111550360.gif";
WindowVote.CreateVote(5,3);
WindowVote.AddContent("没什么意思");
WindowVote.AddContent("一般了");
WindowVote.AddContent("还不错");
WindowVote.AddContent("挺好的");
WindowVote.AddContent("挺酷!");
</script>