Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6320443
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T15:58:25+00:00 2026-05-24T15:58:25+00:00

I’m trying to be clever with JS and jQuery, and using a 3PP called

  • 0

I’m trying to be clever with JS and jQuery, and using a 3PP called ‘Raty’, which simply puts stars into a div, useful when you want to show what rating an item has been given.

Now, here is the javascript I use to dynamically assign values:

$(document).ready(function() {
for (var i = 1; i <=5; i++) {
    var starting = parseInt($('#toplistRating'+i+'val').val());
    $('#toplistRating'+i).raty({
        number: 3,
        half: true,
        readOnly: true,
        start: starting,
        hintList: ['could be improved', 'alright', 'AWESOME']
    });
}

});

And there is a list of items I get from the DB. Here are all 5 (note they are essentially the same, bar some ids being different by 1):

 <div id="toplist" class="std-column">

        <p class="toplist-links">switch to top: <a href="index?toplistSelected=1">1</a> | <a href="index?toplistSelected=2">2</a>
            <a href="index?toplistSelected=3">3</a> | <a href="index?toplistSelected=4">4</a></p>

            <div class="toplist-item">
                <a href="viewpic?id=35">
                <p class="toplist-num">1.</p>
                    <img src="image?id=35&amp;thumbnail=1" class="toplist-pic">
                    <div class="toplist-info">
                        <div id="toplistRating1" style="cursor: default;" title="AWESOME"><img class="toplistRating1" title="AWESOME" alt="1" src="images/star-on.png" id="toplistRating1-1">&nbsp;<img class="toplistRating1" title="AWESOME" alt="2" src="images/star-on.png" id="toplistRating1-2">&nbsp;<img class="toplistRating1" title="AWESOME" alt="3" src="images/star-on.png" id="toplistRating1-3"><input type="hidden" id="toplistRating1-score" name="score" value="3"></div>
                        <input type="hidden" value="6" id="toplistRating1val">
                        <p class="toplist-text"><span class="soft">1 ratings</span></p>
                    </div>
               </a> 
            </div>   

            <div class="toplist-item">
                <a href="viewpic?id=7">
                <p class="toplist-num">2.</p>
                    <img src="image?id=7&amp;thumbnail=1" class="toplist-pic">
                    <div class="toplist-info">
                        <div id="toplistRating2" style="cursor: default;" title="AWESOME"><img class="toplistRating2" title="AWESOME" alt="1" src="images/star-on.png" id="toplistRating2-1">&nbsp;<img class="toplistRating2" title="AWESOME" alt="2" src="images/star-on.png" id="toplistRating2-2">&nbsp;<img class="toplistRating2" title="AWESOME" alt="3" src="images/star-on.png" id="toplistRating2-3"><input type="hidden" id="toplistRating2-score" name="score" value="3"></div>
                        <input type="hidden" value="5" id="toplistRating2val">
                        <p class="toplist-text"><span class="soft">3 ratings</span></p>
                    </div>
               </a> 
            </div>   

            <div class="toplist-item">
                <a href="viewpic?id=11">
                <p class="toplist-num">3.</p>
                    <img src="image?id=11&amp;thumbnail=1" class="toplist-pic">
                    <div class="toplist-info">
                        <div id="toplistRating3" style="cursor: default;" title="AWESOME"><img class="toplistRating3" title="AWESOME" alt="1" src="images/star-on.png" id="toplistRating3-1">&nbsp;<img class="toplistRating3" title="AWESOME" alt="2" src="images/star-on.png" id="toplistRating3-2">&nbsp;<img class="toplistRating3" title="AWESOME" alt="3" src="images/star-on.png" id="toplistRating3-3"><input type="hidden" id="toplistRating3-score" name="score" value="3"></div>
                        <input type="hidden" value="5" id="toplistRating3val">
                        <p class="toplist-text"><span class="soft">5 ratings</span></p>
                    </div>
               </a> 
            </div>   

            <div class="toplist-item">
                <a href="viewpic?id=8">
                <p class="toplist-num">4.</p>
                    <img src="image?id=8&amp;thumbnail=1" class="toplist-pic">
                    <div class="toplist-info">
                        <div id="toplistRating4" style="cursor: default;" title="AWESOME"><img class="toplistRating4" title="AWESOME" alt="1" src="images/star-on.png" id="toplistRating4-1">&nbsp;<img class="toplistRating4" title="AWESOME" alt="2" src="images/star-on.png" id="toplistRating4-2">&nbsp;<img class="toplistRating4" title="AWESOME" alt="3" src="images/star-on.png" id="toplistRating4-3"><input type="hidden" id="toplistRating4-score" name="score" value="3"></div>
                        <input type="hidden" value="4" id="toplistRating4val">
                        <p class="toplist-text"><span class="soft">5 ratings</span></p>
                    </div>
               </a> 
            </div>   

            <div class="toplist-item">
                <a href="viewpic?id=12">
                <p class="toplist-num">5.</p>
                    <img src="image?id=12&amp;thumbnail=1" class="toplist-pic">
                    <div class="toplist-info">
                        <div id="toplistRating5" style="cursor: default;" title="AWESOME"><img class="toplistRating5" title="AWESOME" alt="1" src="images/star-on.png" id="toplistRating5-1">&nbsp;<img class="toplistRating5" title="AWESOME" alt="2" src="images/star-on.png" id="toplistRating5-2">&nbsp;<img class="toplistRating5" title="AWESOME" alt="3" src="images/star-on.png" id="toplistRating5-3"><input type="hidden" id="toplistRating5-score" name="score" value="3"></div>
                        <input type="hidden" value="4" id="toplistRating5val">
                        <p class="toplist-text"><span class="soft">5 ratings</span></p>
                    </div>
               </a> 
            </div>   

    </div>

Raty – http://www.wbotelhos.com/raty/ – only shows 3 Stars (out of 3) for every item, when I know that the scores are lower, like 2 stars for the last 2.

Please help me. I suspect my problem lies with suspect use of javascript, especially that for-loop. If you need more info just let me know and I’ll modify the question.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T15:58:27+00:00Added an answer on May 24, 2026 at 3:58 pm

    The value of starting comes from the hidden input field in the div. From the sample html, these values are all greater than 3.

    6, 5, 5, 4 for the four items mentioned.

    These will max out at 3 since that is the star range.

    Change the values of the hidden input fields to <=3 and you should see different star images.

    If you want to include half stars, then try parseFloat rather than parseInt then / 2.0 afterwards.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am reading a book about Javascript and jQuery and using one of the
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I used javascript for loading a picture on my website depending on which small
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.