五星评论

<script type="text/javascript">
function starover(id){
    for(var i=0; i<5; i++){
        if(i <= parseInt(id)){
            document.getElementById('star'+i).src = "/img/star-solid-med.png";
        }
    }
}

function starout(id){
    for(var i=0; i<5; i++){
        document.getElementById('star'+i).src = "/img/star-clear-med.png";
    }
}

function setRating(url, id){
    var memberId = document.getElementById('memberId').value;
    if(memberId){
        document.getElementById('rating').value = id;
    }else{
        location.href = url + '&rating='+id;
    }
}

</script>

html:

    {if $checkRating}
                        <div style="overflow:hidden;">
                            {$ownStr}
                        </span>
                        <div id="rateNote" style="display:block;overflow:block;color:red;">You have already rated this wine.</div>
                        {else}
                        <div style="overflow:hidden;">
                            <span onmouseover = "document.getElementById('rateNote').style.display='block'" onmouseout = "document.getElementById('rateNote').style.display='none'" style="cursor:pointer;">
                                {section name=loop loop=5}
                                <a style="text-decoration:none;" href="#addComment" rel="shadowbox;width=370;height=250;" onclick="return setRating('{$currentUrl}','{$smarty.section.loop.index+1}')"><img src="/img/star-clear-med.png" title="star" id="star{$smarty.section.loop.index}" onmouseover="starover('{$smarty.section.loop.index}')" onmouseout="starout()"></a>
                                {/section}
                            </span>
                        <div id="rateNote" style="display:block;overflow:hidden;">Please rate this wine on a scale of 1 to 5, with 5 being the highest rating.</div>
  {/if}

所用的图片:

  

猜你喜欢

转载自blog.csdn.net/wccczxm/article/details/5134133