开发者

5 star Javascript

I'm looking for a few pointers on what methods I could use to build a javascript file that will turn a 1-5 dropdown menu to a series of 5 clickable stars (a la old school youtube rating system)

Does not need to perform AJAX, just behav开发者_Go百科e like the drop menu when the form is submitted.


I suggest RateIt, it also comes with examples.


A few jQuery plugins for this exist already, perhaps the most versatile one is this jQuery star rating widget:

http://orkans-tmp.22web.net/star_rating/

Why reinvent the wheel?


  • http://www.nickstakenburg.com/projects/starbox/
  • http://www.google.de/search?q=javascript+star+rating ...


I would start with a search for jQuery plugin - there are surly a few available and you might be able just to reuse one of them.


Make a hidden input named "Rating" and change the value of "Rating" each time a star is click with onclick.

<?php for($i = 1; $i <= 5; $i++) : ?>
    <img src="/folder/star"
    id="star<?php echo $i ?>"
        onclick="
          document.getElementById('form1').elements['rating'].value = <?php echo $i ?>)" />

<form name="form1" id="form1" action="URL">
    <input type="hidden" name="rating" id="rating" value="1" />
        <input type="submit" value="rate" />
</form>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜