// JavaScript Document window.onload = function () { var oStar = document.getElementById("star"); if(oStar!=null){ var aLi = oStar.getElementsByTagName("li"); var oUl = oStar.getElementsByTagName("ul")[0]; var i = iScore = iStar = 0; for (i = 1; i <= aLi.length; i++) { aLi[i - 1].index = i; //鼠标移过显示分数 aLi[i - 1].onmouseover = function () { if(curPersonStar <= 0){ fnPoint(this.index); } }; //鼠标离开后恢复上次评分 aLi[i - 1].onmouseout = function () { if(curPersonStar <= 0){ fnPoint(); } }; //点击后进行评分处理 aLi[i - 1].onclick = function () { if(curPersonStar > 0){ alert("您已经打过分数了,可以再发表发表评价喽!"); }else{ iStar = this.index; //点击每一个星星触发 new AjaxPost(this, { url: '/CourseController/setCourseStar', data: {courseId: $('courseStars').attr('data'), starNumber: iStar}, callback: function(json){ if(json.succ){ $('personCount').txt(new Number($('personCount').txt()) + 1); var html = ''; for(var i = 0; i < new Number(json.html); i++){//修改封面上的平均分 html += ''; } $('courseStars').html(html); $('courseStars').attr('flag', 'true'); //$testRemind($('courseStars'), '评价成功!', 1); //setTimeout('$testRemind.hide()',2000); curPersonStar = iStar; document.getElementById("zs_avgStar").css({width: new Number(json.html)*19}); //修改对话框里面的平均分 }else{ $('courseStars').attr('flag', 'false'); // $testRemind($('courseStars'), '评价失败!', 1); // setTimeout('$testRemind.hide()',2000); } } }).send(); } } } //评分处理 function fnPoint(iArg) { //分数赋值 iScore = iArg || iStar; for (i = 0; i < aLi.length; i++) aLi[i].className = i < iScore ? "on" : ""; } //fnPoint(curPersonStar); //iStar = curPersonStar; } };