星级点评效果

 var sArray = new Object;
		 sArray[0] = new Image;
		 sArray[0].src = "/images/o/dbx.jpg";
		 for (var i=1; i<6; i++) {
		 sArray[i] = new Image();
		 sArray[i].src = "/images/o/dhx.jpg";
         var starTimer;
		 var pro ;
		 var rate ;
		 function initStar() {
		 	try {
			   setProfix("star_");
			   setStars(document.getElementById("commentImg").value,'commentImg');
			   setProfix("taste_");
			   setStars(document.getElementById("taste").value,'taste');
			   setProfix("price_");
			   setStars(document.getElementById("price").value,'price');
			   setProfix("environment_");
			   setStars(document.getElementById("environment").value,'environment');
		 	} catch(e){
		  	}
		 }
		 function showStars(starNum,rate) {
			 try {
			  clearStarTimer();
			  greyStars();
			  colorStars(starNum);
			  } catch(e){}
			  //setStars(starNum,rate);
			 }
		 function setProfix(profix) {
		   pro = profix ;
		 }
		 function colorStars(starNum) {
		  try {
		   for (var i=1; i <= starNum; i++) {
		    var tmpStar = document.getElementById(pro + i);
		    tmpStar.src = sArray[starNum].src;
		   }
		  } catch(e){}
		 }
		 function greyStars() {
		  try {
		   for (var i=1; i<6; i++) {
		    var tmpStar = document.getElementById(pro + i);
		    tmpStar.src = sArray[0].src;
		   }
		  } catch(e){}
		 }
		 function greyAll(curpro,currate) {
		  try {
		   document.getElementById(currate).value ="";
		   for (var i=1; i<6; i++) {
		    var tmpStar = document.getElementById(curpro + i);
		    tmpStar.src = sArray[0].src;
		   }
		  } catch(e){}
		 }
		 function setStars(starNum,rate) {
		  rate = rate ;
		  try {
		   clearStarTimer();
		   var commentImg = document.getElementById(rate);
		   commentImg.value = starNum;
		   showStars(starNum);
		   } catch(e){}
		 }
		 function clearStars(currate) {
		  rate = currate ;
		  try {
		   var commentImg = document.getElementById(rate);
		   if (commentImg.value != '') {
		    setStars(commentImg.value,rate);
		   } else {
		    greyStars();
		   }
		  } catch(e){}
		 }
		 function resetStars() {
		  try {
		   clearStarTimer();
		   var commentImg = document.getElementById(rate);
		   if (commentImg.value != '') {
		    setStars(commentImg.value,rate);
		   } else {
		    greyStars();
		   }
		  } catch(e){}
		 }
		 function clearStarTimer() {
			  if (starTimer) {
			   clearTimeout(starTimer);
			   starTimer = null;
			  }
		  }
		}

 

 

<input type="hidden" id="commentImg" name="commentImg" value="" >
 <a οnmοuseοver="javascript:setProfix('star_');showStars(1,'commentImg');" οnmοuseοut="javascript:setProfix('star_');clearStars('commentImg');" href="javascript:setProfix('star_');setStars(1,'commentImg');"><img src="/images/o/dbx.jpg" id="star_1" width="16" height="16" border="0" alt=""/></a><a οnmοuseοver="javascript:setProfix('star_');showStars(2,'commentImg');" οnmοuseοut="javascript:setProfix('star_');clearStars('commentImg');" href="javascript:setProfix('star_');setStars(2,'commentImg');"><img src="/images/o/dbx.jpg" id="star_2" width="16" height="16" border="0" alt=""/></a><a οnmοuseοver="javascript:setProfix('star_');showStars(3,'commentImg');" οnmοuseοut="javascript:setProfix('star_');clearStars('commentImg');" href="javascript:setProfix('star_');setStars(3,'commentImg');"><img src="/images/o/dbx.jpg" id="star_3" width="16" height="16" border="0" alt=""/></a><a οnmοuseοver="javascript:setProfix('star_');showStars(4,'commentImg');" οnmοuseοut="javascript:setProfix('star_');clearStars('commentImg');" href="javascript:setProfix('star_');setStars(4,'commentImg');"><img src="/images/o/dbx.jpg" id="star_4" width="16" height="16" border="0" alt=""/></a><a οnmοuseοver="javascript:setProfix('star_');showStars(5,'commentImg');" οnmοuseοut="javascript:setProfix('star_');clearStars('commentImg');" href="javascript:setProfix('star_');setStars(5,'commentImg');"><img src="/images/o/dbx.jpg" id="star_5" width="16" height="16" border="0" alt=""/></a>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值