码迷,mamicode.com
首页 > Web开发 > 详细

商品评价小星星打分js

时间:2014-12-11 11:41:04      阅读:195      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   io   ar   color   sp   for   java   

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
        <title>星星打分</title>
        
        <style type="text/css">
        .evalInfo{
            font-size: 13px;
            font-family: ‘宋体‘;
            margin: 3 5px;
        }
        </style>
        <script type="text/javascript">

/** 用星星的方式来打分, **/
function evalSorce(rootEle, oEvent, targetObjId,attitudeTitleId) {
 var imgs = rootEle.getElementsByTagName("img");
 //var e = oEvent || window.event;
 var eventTarget = window.event.srcElement||eventTag.target; 
 var clickedImgValue = eventTarget.value;
 
 for(var i=0; i<imgs.length; i++) {
     var tempImg = imgs[i];
     if(tempImg.value <= clickedImgValue){
         tempImg.src =/JSTest/img/bright.gif;
     }else {
         tempImg.src =/JSTest/img/dark.gif;
     }
 }
 var targetObj =  document.getElementById(targetObjId);
 targetObj.value = clickedImgValue;
 var attitudeTitle = document.getElementById(attitudeTitleId);
 attitudeTitle.innerHTML = eventTarget.title;
 
}
</script>
    </head>
    <body>
        <input name="attitude" id="attitudeId" value="0">
        <span onclick="evalSorce(this, event, ‘attitudeId‘,‘attitudeTitle‘)">
            <img title="非常差" value=‘1‘ src=‘/JSTest/img/dark.gif‘ />
            <img title="较差"   value=‘2‘ src=‘/JSTest/img/dark.gif‘ />
            <img title="一般"   value=‘3‘ src=‘/JSTest/img/dark.gif‘ /> 
            <img title="较好" value=‘4‘ src=‘/JSTest/img/dark.gif‘ />
            <img title="非常好" value=‘5‘ src=‘/JSTest/img/dark.gif‘ />
            <span id="attitudeTitle" class=‘evalInfo‘></span>
        </span>
    </body>
</html>

摘自:http://www.cnblogs.com/java-boy/archive/2011/09/01/2162578.html

商品评价小星星打分js

标签:style   blog   http   io   ar   color   sp   for   java   

原文地址:http://www.cnblogs.com/dnzhu/p/4157055.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!