http://www.masugadesign.com/the-lab/scripts/unobtrusive-ajax-star-rating-bar/

Does anyone know how I could do a top 10 list within a table that has every second "table" in diferent colors with different pictures that will show up based up on the rating is an odd or even number (1=blue 2= grey, 3,=blue, ect.)

Look at this picture if it doesnt make sense

http://www.pokerdream.tk/lookhere.jpg

Recommended Answers

All 7 Replies

Member Avatar for Dukane

As you are iterating through the table, count rows. If the row number is odd, make it blue. If not, make it grey.

Hmm.. can it be so simple? To me, when I see the "toplist"-code I feel it could be alot harder (??).

Member Avatar for Dukane

Whoops! I'm sorry I misread your problem. But the solution (to what I think you want to do) isn't too far off.

As you are reading through the list of Top 10, divide the rating by 2. If the result comes out as an integer, the rating was EVEN. (0, 2, 4, 6, 8 or 10). If the result has a fractional part the rating will be ODD (1, 3, 5, 7, 9 - these numbers are not equally divisible by 2).

As you get this even/odd information, set it to a variable--say a boolean variable. If the variable is true, then color the table one way (say blue for even) and if it is false, then color the table the other way (say grey for odd).

Hmm..

How can I do that - I'm not the best programmer..

??

Can someone help me ?

Integer division:

a = Math.floor(b/2);

Test for odd:

a = Math.floor(b/2);
if(b - a*2 > .0001){
  // code if b is odd

}
else{
  // code if b is even

};

thank you, I'll see if I can make it right in someway-

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.